├── xabber-server-files ├── linux │ └── linux-x86_64 │ │ ├── libexpat.so.1 │ │ ├── libssl.so.1.1 │ │ ├── libtinfo.so.5 │ │ ├── libyaml-0.so.2 │ │ ├── libcrypto.so.1.1 │ │ ├── libexpat.so.1.6.0 │ │ ├── libncurses.so.5 │ │ ├── libssl.so.1.0.0 │ │ ├── libcrypto.so.1.0.0 │ │ └── libcrypto.so.1.0.2 ├── dig ├── 001-site.conf ├── psql_stuff │ ├── psql.bin │ ├── psql_lib │ │ ├── libffi.so.6 │ │ ├── libpq.so.5 │ │ ├── libasn1.so.8 │ │ ├── libedit.so.0 │ │ ├── libgmp.so.10 │ │ ├── libhx509.so.5 │ │ ├── libidn.so.11 │ │ ├── libkrb5.so.26 │ │ ├── libkrb5.so.3 │ │ ├── libsasl2.so.2 │ │ ├── libtasn1.so.6 │ │ ├── libtinfo.so.5 │ │ ├── libwind.so.0 │ │ ├── libgnutls.so.30 │ │ ├── libgssapi.so.3 │ │ ├── libhcrypto.so.4 │ │ ├── libheimbase.so.1 │ │ ├── libheimntlm.so.0 │ │ ├── libhogweed.so.4 │ │ ├── libk5crypto.so.3 │ │ ├── libkeyutils.so.1 │ │ ├── liblber-2.4.so.2 │ │ ├── libncurses.so.5 │ │ ├── libp11-kit.so.0 │ │ ├── libroken.so.18 │ │ ├── libsqlite3.so.0 │ │ ├── libssl.so.1.0.0 │ │ ├── libcrypto.so.1.0.0 │ │ ├── libldap_r-2.4.so.2 │ │ ├── libgssapi_krb5.so.2 │ │ └── libkrb5support.so.0 │ ├── psql │ └── pg.sql ├── xabberserver.service0 ├── 001-site-ssl.conf ├── xabber.text ├── erl ├── server.pem ├── ejabberdctl ├── pg.old.sql └── setup.sh ├── .gitignore ├── update_menu.png ├── xabber-server.png ├── .gitmodules ├── .github └── FUNDING.yml └── COPYING /xabber-server-files/linux/linux-x86_64/libexpat.so.1: -------------------------------------------------------------------------------- 1 | libexpat.so.1.6.0 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | xabberserver/ 2 | xabber-web/ 3 | makeself/ 4 | xabberserver_installer* 5 | -------------------------------------------------------------------------------- /update_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/update_menu.png -------------------------------------------------------------------------------- /xabber-server.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server.png -------------------------------------------------------------------------------- /xabber-server-files/dig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/dig -------------------------------------------------------------------------------- /xabber-server-files/001-site.conf: -------------------------------------------------------------------------------- 1 | 2 | ServerName DOMAIN 3 | Redirect / https://DOMAIN/ 4 | 5 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "create-release"] 2 | path = create-release 3 | url = https://github.com/redsolution/create-release.git 4 | -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/psql_stuff/psql.bin -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql_lib/libffi.so.6: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/psql_stuff/psql_lib/libffi.so.6 -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql_lib/libpq.so.5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/psql_stuff/psql_lib/libpq.so.5 -------------------------------------------------------------------------------- /xabber-server-files/linux/linux-x86_64/libssl.so.1.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/linux/linux-x86_64/libssl.so.1.1 -------------------------------------------------------------------------------- /xabber-server-files/linux/linux-x86_64/libtinfo.so.5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/linux/linux-x86_64/libtinfo.so.5 -------------------------------------------------------------------------------- /xabber-server-files/linux/linux-x86_64/libyaml-0.so.2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/linux/linux-x86_64/libyaml-0.so.2 -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql_lib/libasn1.so.8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/psql_stuff/psql_lib/libasn1.so.8 -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql_lib/libedit.so.0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/psql_stuff/psql_lib/libedit.so.0 -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql_lib/libgmp.so.10: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/psql_stuff/psql_lib/libgmp.so.10 -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql_lib/libhx509.so.5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/psql_stuff/psql_lib/libhx509.so.5 -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql_lib/libidn.so.11: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/psql_stuff/psql_lib/libidn.so.11 -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql_lib/libkrb5.so.26: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/psql_stuff/psql_lib/libkrb5.so.26 -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql_lib/libkrb5.so.3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/psql_stuff/psql_lib/libkrb5.so.3 -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql_lib/libsasl2.so.2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/psql_stuff/psql_lib/libsasl2.so.2 -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql_lib/libtasn1.so.6: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/psql_stuff/psql_lib/libtasn1.so.6 -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql_lib/libtinfo.so.5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/psql_stuff/psql_lib/libtinfo.so.5 -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql_lib/libwind.so.0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/psql_stuff/psql_lib/libwind.so.0 -------------------------------------------------------------------------------- /xabber-server-files/linux/linux-x86_64/libcrypto.so.1.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/linux/linux-x86_64/libcrypto.so.1.1 -------------------------------------------------------------------------------- /xabber-server-files/linux/linux-x86_64/libexpat.so.1.6.0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/linux/linux-x86_64/libexpat.so.1.6.0 -------------------------------------------------------------------------------- /xabber-server-files/linux/linux-x86_64/libncurses.so.5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/linux/linux-x86_64/libncurses.so.5 -------------------------------------------------------------------------------- /xabber-server-files/linux/linux-x86_64/libssl.so.1.0.0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/linux/linux-x86_64/libssl.so.1.0.0 -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql_lib/libgnutls.so.30: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/psql_stuff/psql_lib/libgnutls.so.30 -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql_lib/libgssapi.so.3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/psql_stuff/psql_lib/libgssapi.so.3 -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql_lib/libhcrypto.so.4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/psql_stuff/psql_lib/libhcrypto.so.4 -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql_lib/libheimbase.so.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/psql_stuff/psql_lib/libheimbase.so.1 -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql_lib/libheimntlm.so.0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/psql_stuff/psql_lib/libheimntlm.so.0 -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql_lib/libhogweed.so.4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/psql_stuff/psql_lib/libhogweed.so.4 -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql_lib/libk5crypto.so.3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/psql_stuff/psql_lib/libk5crypto.so.3 -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql_lib/libkeyutils.so.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/psql_stuff/psql_lib/libkeyutils.so.1 -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql_lib/liblber-2.4.so.2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/psql_stuff/psql_lib/liblber-2.4.so.2 -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql_lib/libncurses.so.5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/psql_stuff/psql_lib/libncurses.so.5 -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql_lib/libp11-kit.so.0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/psql_stuff/psql_lib/libp11-kit.so.0 -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql_lib/libroken.so.18: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/psql_stuff/psql_lib/libroken.so.18 -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql_lib/libsqlite3.so.0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/psql_stuff/psql_lib/libsqlite3.so.0 -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql_lib/libssl.so.1.0.0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/psql_stuff/psql_lib/libssl.so.1.0.0 -------------------------------------------------------------------------------- /xabber-server-files/linux/linux-x86_64/libcrypto.so.1.0.0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/linux/linux-x86_64/libcrypto.so.1.0.0 -------------------------------------------------------------------------------- /xabber-server-files/linux/linux-x86_64/libcrypto.so.1.0.2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/linux/linux-x86_64/libcrypto.so.1.0.2 -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql_lib/libcrypto.so.1.0.0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/psql_stuff/psql_lib/libcrypto.so.1.0.0 -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql_lib/libldap_r-2.4.so.2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/psql_stuff/psql_lib/libldap_r-2.4.so.2 -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql_lib/libgssapi_krb5.so.2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/psql_stuff/psql_lib/libgssapi_krb5.so.2 -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql_lib/libkrb5support.so.0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redsolution/xabber-server/HEAD/xabber-server-files/psql_stuff/psql_lib/libkrb5support.so.0 -------------------------------------------------------------------------------- /xabber-server-files/xabberserver.service0: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Xabber Server 3 | After=network.target 4 | 5 | [Service] 6 | Type=forking 7 | PIDFile=INSTALL_PATH/xabber_server.pid 8 | User=USER 9 | Group=GROUP 10 | LimitNOFILE=65536 11 | Restart=on-failure 12 | RestartSec=5 13 | ExecStart=INSTALL_PATH/xmppserverui/service.sh start 14 | ExecStop=INSTALL_PATH/xmppserverui/service.sh stop 15 | PrivateDevices=true 16 | ProtectSystem=full 17 | 18 | [Install] 19 | WantedBy=multi-user.target 20 | -------------------------------------------------------------------------------- /xabber-server-files/001-site-ssl.conf: -------------------------------------------------------------------------------- 1 | 2 | ServerName DOMAIN 3 | 4 | ProxyPreserveHost On 5 | 6 | ProxyPass /upload http://127.0.0.1:5280/upload/ 7 | ProxyPassReverse /upload http://127.0.0.1:5280/upload/ 8 | 9 | ProxyPass / http://localhost:8000/ 10 | ProxyPassReverse / http://localhost:8000/ 11 | 12 | SSLEngine On 13 | SSLCertificateFile /etc/letsencrypt/live/DOMAIN/cert.pem 14 | SSLCertificateKeyFile /etc/letsencrypt/live/DOMAIN/privkey.pem 15 | 16 | 17 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: xabber 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/psql: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # If there's an OS supplied version of libreadline, try to make use of it, 4 | # as it's more reliable than libedit, which we link with. 5 | PLL="" 6 | if [ -f /lib64/libreadline.so.6 ]; 7 | then 8 | PLL=/lib64/libreadline.so.6 9 | elif [ -f /lib64/libreadline.so.5 ]; 10 | then 11 | PLL=$PLL:/lib64/libreadline.so.5 12 | elif [ -f /lib/libreadline.so.6 ]; 13 | then 14 | PLL=$PLL:/lib/libreadline.so.6 15 | elif [ -f /lib/libreadline.so.5 ]; 16 | then 17 | PLL=$PLL:/lib/libreadline.so.5 18 | fi 19 | # Get the PG bin directory path relative to psql caller script. 20 | PG_BIN_PATH=`dirname "$0"` 21 | 22 | echo $PLL 23 | if [ -z "$PLL" ]; 24 | then 25 | LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PG_BIN_PATH/psql_lib "$PG_BIN_PATH/psql.bin" "$@" 26 | else 27 | LD_PRELOAD=$PLL LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PG_BIN_PATH/ "$PG_BIN_PATH/psql.bin" "$@" 28 | fi 29 | 30 | -------------------------------------------------------------------------------- /xabber-server-files/xabber.text: -------------------------------------------------------------------------------- 1 | 2 | ...... 3 | 'cd0MMMNWWNOl; 4 | .ckk0KNWW0Okdxolol:. 5 | ;oNMMMMW0Okxdoxolc:;:, 6 | ;kNMMMMM0O00K00Odco;;,'' 7 | .0WWMMMW0dddoooood:cll;.,. 8 | :NWWWMM0llllllcc:odcxNX;c, 9 | ;dxNWWWNkdddlc:;;;:xWWWOx' 10 | o,:dKWWWWWWO;;,::0WWNNXd 11 | .d,'dWWWWWWN;,',dONNXKk. 12 | .c:oNWWWWWWo.;O00K0Ol 13 | .:OXXXXXXKO000Od;. 14 | dk0Okdddd0xl 15 | ;kOkxdoolxd; 16 | :k0Okddooxx: 17 | ,dOOkxddddc. 18 | .'::.. 19 | 20 | 21 | __ __ _ _ ____ 22 | \ \/ /__ _| |__ | |__ ___ _ __ / ___| ___ _ ____ _____ _ __ 23 | \ // _` | '_ \| '_ \ / _ \ '__| \___ \ / _ \ '__\ \ / / _ \ '__| 24 | / \ (_| | |_) | |_) | __/ | ___) | __/ | \ V / __/ | 25 | /_/\_\__,_|_.__/|_.__/ \___|_| |____/ \___|_| \_/ \___|_| 26 | 27 | -------------------------------------------------------------------------------- /xabber-server-files/erl: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ## This script replaces the default "erl" in erts-VSN/bin. This is necessary 4 | ## as escript depends on erl and in turn, erl depends on having access to a 5 | ## bootscript (start.boot). Note that this script is ONLY invoked as a side-effect 6 | ## of running escript -- the embedded node bypasses erl and uses erlexec directly 7 | ## (as it should). 8 | ## 9 | ## Note that this script makes the assumption that there is a start_clean.boot 10 | ## file available in $ROOTDIR/release/VSN. 11 | 12 | # Determine the abspath of where this script is executing from. 13 | ERTS_BIN_DIR=$(cd ${0%/*} && pwd) 14 | 15 | # Now determine the root directory -- this script runs from erts-VSN/bin, 16 | # so we simply need to strip off two dirs from the end of the ERTS_BIN_DIR 17 | # path. 18 | ROOTDIR=${ERTS_BIN_DIR%/*/*} 19 | 20 | # Parse out release and erts info 21 | START_ERL=`cat $ROOTDIR/releases/start_erl.data` 22 | ERTS_VSN=${START_ERL% *} 23 | APP_VSN=${START_ERL#* } 24 | 25 | BINDIR=$ROOTDIR/erts-$ERTS_VSN/bin 26 | EMU=beam 27 | PROGNAME=`echo $0 | sed 's/.*\\///'` 28 | CMD="$BINDIR/erlexec" 29 | export EMU 30 | export ROOTDIR 31 | export BINDIR 32 | export PROGNAME 33 | 34 | case `uname -m` in 35 | i[3456]86) cpu="x86" ;; 36 | i86pc) cpu="x86" ;; 37 | armv7*) cpu="armhf" ;; 38 | *) cpu=`uname -m | tr A-Z a-z` ;; 39 | esac 40 | os=`uname -s | tr A-Z a-z` 41 | LD_LIBRARY_PATH=$ROOTDIR/lib/${os}-${cpu} 42 | export LD_LIBRARY_PATH 43 | DYLD_LIBRARY_PATH="$LD_LIBRARY_PATH" 44 | export DYLD_LIBRARY_PATH 45 | 46 | exec $CMD -boot $ROOTDIR/releases/$APP_VSN/start_clean ${1+"$@"} 47 | -------------------------------------------------------------------------------- /xabber-server-files/server.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIIJQwIBADANBgkqhkiG9w0BAQEFAASCCS0wggkpAgEAAoICAQCS3PDdJNo5aLRX 3 | BGCyRp2UY0K2oSTUL0evEal4TSy3Sx7pko0X76TUuJllNZNZnJjhXcU80tfFaJFk 4 | D7pqJFQ6M7+J9Kh6KkI07M4v1GtiCaHZkT93uS0NdeGqvtM9YMkq8PvuOSdLKGu4 5 | oE0Fo1ne6MdH1O6okVJOm7H9C/WFixmdrta8Mo5KuGKX9xMLtmQVsqYoJldK4OIt 6 | UM3qVIStX1UEslWUEiD9zV5cPoht1Kb85oHgBmPXl/+p0CBlaudj4emv7dneH/wu 7 | UxYzCBRsgXxoz8wSUnAp0aMY0B31glWYnre2IEzlkWqKtJRK27LLwLrhTGwxu3sx 8 | MzVpsQNPTUvfteHFtrV0x8xk+a+M3Cbu7QsTgVdTBvl1vTyMXgsFx5xZTUKwXyV/ 9 | GDx7sh+T6bQZlf0ko2j5DqSRjZux7kLXafxBSBvuXEMWCn9olgo9o2f45SBiUgdw 10 | o1LjRrKhvlY6nq5rh496+B7IzHcd1O+5W+ZFbmLqPOSYhLExeR4LTkqGekJEfG7n 11 | z6txdnFQwgpXC8TzhX7LYqA+/Dn0OOvHsqSecWLtbo1CMKxEvhsJaYbZ6uoNS8S8 12 | 3a3Sqt9HyYzlSWJPBs4q8QdqPApqIcJxFqHkuosXobk80bv6hTFrtHGZL1zo1G4h 13 | MEhOTKtAjZNMVtLGyLTWiHiwoOtZfQIDAQABAoICAFshpIjlZFC5ayaP/dzCOugo 14 | S+59whe0mvvEru+KnBPFFpKDsO/IcfTZ87286Al0Rd2azVh30RKbV5TKubdBgc53 15 | 7AQUADOGY3zp8Ov3GQdFyNvz6HlHO/CdVIIaVYRBubLexMXHS1204Fs5hXHZMlxC 16 | /93QAKQzQOqsbF8Ee775WNTi+Dbh/C/biLqZw4TCEgrwx3AkkohRUagi+xPMjGP0 17 | wxHeA4KVWUmElWgSGaBlk5VdB/xWmr/efvQFxQSJuLnfJp5XrpjKKjcosZ7LBblr 18 | BCMZxp0b8KPShS1RfzWoQasp2f+2vWC6wmz9rwNgnusWViCVxpF5r/EQwLUr9Uvg 19 | m+YXR+aoPc1H9OAMhGLp23RoM+FdnWCmTg4eavvkTexas7LlmQna9r+7pIQkV/1y 20 | TVgwLMPaJfecf5SY/mQTnGbp40ZtFpESlhHA6R+YEqXxAmX3ddnyAS60K3kmxrpC 21 | PRVZJzDHMNIJVxto96f0tnhdee78ra/lYBEMUscU9gNV6TuR1hvKMH82Km1NXHmV 22 | fXJN7H0zKI1sN2WkGVI8D526sHdTMisq33mcmGMcoai8D8iJDSHktIei6IgPOaQw 23 | npsQTCRQB6OsQDEp0Qw7xJuquCRcsafoiWl03KuY2pH2LDcyA6YpUFfsXsAlpGQq 24 | SDT6MvNo1/Tm3ehtH0K1AoIBAQDCct1oB2rmhLxjIIlkdc3Y7BwuYgi6ODxYs5Ne 25 | titwrZcJvyQ3uKNB2gfnsD8oPfuDbUOWmcdWmPC6ZSIH7C3VgTXA/Ozu3wIqyJKN 26 | dMKcy6LOTsr5or3XOmBWjrIS7nV7oZw0WKzRluqMpMh59x6AzwTK34KHWyZ+IDQ6 27 | /n3XiCsx2RzWeC9/bbKsjl6t3eeg1J0xinnMdHCN32YNfxQ+3A38v2WQZuOXJFmA 28 | p8atyFLReL0knkUSXV3en7Z79m64ajRmDZEGRgazHmRVUnD4TibUuAhXvvJ3F0oS 29 | W92yuIXkQ2RknmP5U7qzqQqpSnMPR2JEgHkBioffymMJlvcrAoIBAQDBWfooPxnN 30 | tqZqiYy/blaiGFs0TM9eVgLVoz5BO8Y2Yddccrq9BNoRaYnyRP2dRn/qkwpc2crt 31 | tVysW65K6k+nHY+Q/+GoOmJ9D+YbRJjij+E+lp1Cz3AEj4gV9fIzMbgCrTfsq48r 32 | GUv/ha4b08Wp8F2E6BbK3+0SWLTPu6G8buNxEEPEuh0lEIIdazklkUITWRe/LhLQ 33 | Wj3LJfJMYz75AtdATZGKSUhQJPnpC1MLHLzDzWVOleTUcp4++ud2wbJOidy6KqGC 34 | evygvjoRb3Xkj/xHZDKvfvh6FiK5/6ndhNwDcjPr+6LlX5mhIqacy+OAuV1JdcqX 35 | Qf2i/cnhSR33AoIBAQCww+zkWgHjJv1++6AKtFD6BsIjpDkc2Gx7klvA+MgKubOZ 36 | R6qsAOxgu8z94Sm48ofHVTfhG1CsN4J3X+KM4zZTZg+wrfzRtedpb0ZS07brBO+u 37 | rtA0Ga6MjuPvK+9T6HTie+rdZ1NLgO8eBdq9jVmsbQWFS6SEWednNu1kR9+sZHwn 38 | 56Agk8dSBy4rUY1eb2DWwxFXbPQGWj/LqS9Dy6di8XbBslio6e+xgXjfzSV+66Hm 39 | DOWc+Uf/RuNDs1sX29GRUfLqZyDUXCpRAKrjKXvLLnh8XgQviEUw3/oVMHAcvUPy 40 | WxVTpu1pRaVvF5e6iBSK6jC55zSZow6b8YcQu61bAoIBADD5cXuwQADzOsPRg20Z 41 | rafxM2jT69KhRqaGasZrNZGgxsQL63DlQbcXXHGZOAQWT2BDTmSmZdhAD/E4Z7Vi 42 | FDroKe04YxgRcdDrrgVKIs+AUjVgQQUjNeRx1q55VZfSCCHlbjzsV587ERzv52H1 43 | CiQ5VfbMMrnAbnQvM91KUXVBQSrqS8AQxEEXJV3+QsNZP7tW3cT3Dpznvq8uNWlT 44 | 2ieIqK0I+MxmM4LZWtPEoow2Azo1VGvLW+LUBXE+bFKQTXHHSbl+Atrh/AtbI6o2 45 | 6U2zitsqbgw1xQpngPRL5eLOPExDKROk8WXYCTnfZQRiQIXibdall2Mou+4FCpWd 46 | x5ECggEBAIpq+KRsIFnIbbNYYNBiIimOXM4up69/B693Dngpq8cfRCVCJiSK2IiC 47 | 31wZsAIuSWI11fi59GYPcQjKAazt9VXjyEtTTa6uu8LgHJGSiNKeViFN888g6mkE 48 | OLTYIWnL20sljJQHvwVaKibzpa6iN4Pn65JyhuEsJga/HgrPsk0Fhc0X2yKMNQ+V 49 | y0suXGVDweoivAhfRcr7BLXpUCi0eX0AK59dayCvZJmdfv7iXGsAwPQAK4wVu6au 50 | fdRWOFknYLJztCx2X/BRVlen8Rqbq34VbzIR6pSCxLYT63CciFbQoR2flQCqynUo 51 | afuWkuBZwh3y7XU2UeNinKXsgnIpdvY= 52 | -----END PRIVATE KEY----- 53 | -----BEGIN CERTIFICATE----- 54 | MIIF5TCCA82gAwIBAgIUIrVYVezQsbVt+9zwG+exxH2u8UEwDQYJKoZIhvcNAQEL 55 | BQAwgYExCzAJBgNVBAYTAkVFMRYwFAYDVQQIDA1IYXJqdSBtYWFrb25kMRQwEgYD 56 | VQQKDAtSZWRzb2x1dGlvbjELMAkGA1UECwwCSVQxEjAQBgNVBAMMCWxvY2FsaG9z 57 | dDEjMCEGCSqGSIb3DQEJARYUaW5mb0ByZWRzb2x1dGlvbi5jb20wHhcNMTkwNzEx 58 | MTEyMDA1WhcNMjkwNzA4MTEyMDA1WjCBgTELMAkGA1UEBhMCRUUxFjAUBgNVBAgM 59 | DUhhcmp1IG1hYWtvbmQxFDASBgNVBAoMC1JlZHNvbHV0aW9uMQswCQYDVQQLDAJJ 60 | VDESMBAGA1UEAwwJbG9jYWxob3N0MSMwIQYJKoZIhvcNAQkBFhRpbmZvQHJlZHNv 61 | bHV0aW9uLmNvbTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAJLc8N0k 62 | 2jlotFcEYLJGnZRjQrahJNQvR68RqXhNLLdLHumSjRfvpNS4mWU1k1mcmOFdxTzS 63 | 18VokWQPumokVDozv4n0qHoqQjTszi/Ua2IJodmRP3e5LQ114aq+0z1gySrw++45 64 | J0soa7igTQWjWd7ox0fU7qiRUk6bsf0L9YWLGZ2u1rwyjkq4Ypf3Ewu2ZBWypigm 65 | V0rg4i1QzepUhK1fVQSyVZQSIP3NXlw+iG3UpvzmgeAGY9eX/6nQIGVq52Ph6a/t 66 | 2d4f/C5TFjMIFGyBfGjPzBJScCnRoxjQHfWCVZiet7YgTOWRaoq0lErbssvAuuFM 67 | bDG7ezEzNWmxA09NS9+14cW2tXTHzGT5r4zcJu7tCxOBV1MG+XW9PIxeCwXHnFlN 68 | QrBfJX8YPHuyH5PptBmV/SSjaPkOpJGNm7HuQtdp/EFIG+5cQxYKf2iWCj2jZ/jl 69 | IGJSB3CjUuNGsqG+VjqermuHj3r4HsjMdx3U77lb5kVuYuo85JiEsTF5HgtOSoZ6 70 | QkR8bufPq3F2cVDCClcLxPOFfstioD78OfQ468eypJ5xYu1ujUIwrES+Gwlphtnq 71 | 6g1LxLzdrdKq30fJjOVJYk8GzirxB2o8CmohwnEWoeS6ixehuTzRu/qFMWu0cZkv 72 | XOjUbiEwSE5Mq0CNk0xW0sbItNaIeLCg61l9AgMBAAGjUzBRMB0GA1UdDgQWBBSl 73 | y9pi2/wbiHYlyF6amN3Me4E7DzAfBgNVHSMEGDAWgBSly9pi2/wbiHYlyF6amN3M 74 | e4E7DzAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4ICAQA0zQhuB64a 75 | IlWCdgjC93t602x8Fhd89LaxV7rDjjv8oWEY1pw3b59WRigL4X1sEiL+8qzfXBHz 76 | +IVww+DiVLPHTcgBu1Qznaxr5LLCzs9PwNtIol16S6EkbM7UHgKlTQco/XPk1i8v 77 | wcvt8du6UChTUjly89SBPIRWkLZaltE/NfVcYXmOP3MdTBif0aXqhDODluO1iknH 78 | saPEWjMluz7tsa9/Lt/9XFtO8qpUEY4F9ontOZcWRvuIzAREKGzimyydjWlTDEFN 79 | nr6S0I0wYJejoGYMCJ8TxE+12hAe2rDlejt2Ih2EQbzzPlLk+QBAB6vPhQIgalgn 80 | Km03vAJ9xPaXdJhA58jYU7cI0bbcCRmqYNk4HFWWGs3JlC9dLIFcLWdkph/4Stqd 81 | KGizDzEZCmRzhDO14TpalJPDDWlCPyQr83aBRWb142iMGTW+/0icR+WowVmcQ/QK 82 | e6U6dCftfvZIzky4YACFlyzpUr1shEnYgLMDHIIQGPdAKZuVx7h4l1hnvdhOljit 83 | XhaIkSknwlAlolCf6c2j1kVDiTrYjcdQGxLqfZ2YFbAABbE6K2SjTsoyYh3aRToF 84 | ZLdF+YBxbkQ66+JmWiGKsrf0yQied38fP24sgC+Y9S3JV1h1QHuSg2lAja2rdRNb 85 | 7ZD+2/7iR1NA9yCKMCexF1iaZoCj9CirCA== 86 | -----END CERTIFICATE----- 87 | -------------------------------------------------------------------------------- /xabber-server-files/ejabberdctl: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # define default configuration 4 | POLL=true 5 | SMP=auto 6 | ERL_MAX_PORTS=32000 7 | ERL_PROCESSES=250000 8 | ERL_MAX_ETS_TABLES=1400 9 | FIREWALL_WINDOW="" 10 | INET_DIST_INTERFACE="" 11 | ERLANG_NODE=ejabberd@localhost 12 | 13 | # define default environment variables 14 | SCRIPT_DIR=$(cd "${0%/*}" && pwd) 15 | FILE="$SCRIPT_DIR/blocked" 16 | ERL="${SCRIPT_DIR%/*}/erts-8.2.1/bin/erl" 17 | IEX="/iex" 18 | EPMD="${SCRIPT_DIR%/*}/erts-8.2.1/bin/epmd" 19 | INSTALLUSER="" 20 | 21 | # check the proper system user is used 22 | case $(id -un) in 23 | "$INSTALLUSER") 24 | EXEC_CMD="as_current_user" 25 | ;; 26 | root) 27 | if [ -n "$INSTALLUSER" ] ; then 28 | EXEC_CMD="as_install_user" 29 | else 30 | EXEC_CMD="as_current_user" 31 | echo "WARNING: It is not recommended to run ejabberd as root" >&2 32 | fi 33 | ;; 34 | *) 35 | if [ -n "$INSTALLUSER" ] ; then 36 | echo "ERROR: This command can only be run by root or the user $INSTALLUSER" >&2 37 | exit 7 38 | else 39 | EXEC_CMD="as_current_user" 40 | fi 41 | ;; 42 | esac 43 | 44 | # parse command line parameters 45 | for arg; do 46 | case $arg in 47 | -n|--node) ERLANG_NODE_ARG=$2; shift;; 48 | -s|--spool) SPOOL_DIR=$2; shift;; 49 | -l|--logs) LOGS_DIR=$2; shift;; 50 | -f|--config) EJABBERD_CONFIG_PATH=$2; shift;; 51 | -c|--ctl-config) EJABBERDCTL_CONFIG_PATH=$2; shift;; 52 | -d|--config-dir) ETC_DIR=$2; shift;; 53 | -t|--no-timeout) NO_TIMEOUT="--no-timeout";; 54 | --) :;; 55 | *) break;; 56 | esac 57 | shift 58 | done 59 | 60 | # define ejabberd variables if not already defined from the command line 61 | : "${ETC_DIR:="${SCRIPT_DIR%/*}/etc/ejabberd"}" 62 | : "${LOGS_DIR:="${SCRIPT_DIR%/*}/var/log/ejabberd"}" 63 | : "${SPOOL_DIR:="${SCRIPT_DIR%/*}/var/lib/ejabberd"}" 64 | : "${EJABBERD_CONFIG_PATH:="$ETC_DIR/ejabberd.yml"}" 65 | : "${EJABBERDCTL_CONFIG_PATH:="$ETC_DIR/ejabberdctl.cfg"}" 66 | [ -f "$EJABBERDCTL_CONFIG_PATH" ] && . "$EJABBERDCTL_CONFIG_PATH" 67 | [ -n "$ERLANG_NODE_ARG" ] && ERLANG_NODE="$ERLANG_NODE_ARG" 68 | [ "$ERLANG_NODE" = "${ERLANG_NODE%.*}" ] && S="-s" 69 | : "${EJABBERD_DOC_PATH:="${SCRIPT_DIR%/*}/doc"}" 70 | : "${EJABBERD_LOG_PATH:="$LOGS_DIR/ejabberd.log"}" 71 | 72 | # define erl parameters 73 | ERLANG_OPTS="+K $POLL -smp $SMP +P $ERL_PROCESSES $ERL_OPTIONS" 74 | if [ -n "$FIREWALL_WINDOW" ] ; then 75 | ERLANG_OPTS="$ERLANG_OPTS -kernel inet_dist_listen_min ${FIREWALL_WINDOW%-*} inet_dist_listen_max ${FIREWALL_WINDOW#*-}" 76 | fi 77 | if [ -n "$INET_DIST_INTERFACE" ] ; then 78 | INET_DIST_INTERFACE2=$("$ERL" -noshell -eval 'case inet:parse_address("'$INET_DIST_INTERFACE'") of {ok,IP} -> io:format("~p",[IP]); _ -> ok end.' -s erlang halt) 79 | if [ -n "$INET_DIST_INTERFACE2" ] ; then 80 | ERLANG_OPTS="$ERLANG_OPTS -kernel inet_dist_use_interface $INET_DIST_INTERFACE2" 81 | fi 82 | fi 83 | ERL_LIBS=${SCRIPT_DIR%/*}/lib 84 | ERL_CRASH_DUMP="$LOGS_DIR"/erl_crash_$(date "+%Y%m%d-%H%M%S").dump 85 | ERL_INETRC="$ETC_DIR"/inetrc 86 | 87 | # define ejabberd parameters 88 | EJABBERD_OPTS="$EJABBERD_OPTS\ 89 | $(sed '/^log_rate_limit/!d;s/:[ \t]*\([0-9]*\).*/ \1/;s/^/ /' "$EJABBERD_CONFIG_PATH")\ 90 | $(sed '/^log_rotate_size/!d;s/:[ \t]*\([0-9]*\).*/ \1/;s/^/ /' "$EJABBERD_CONFIG_PATH")\ 91 | $(sed '/^log_rotate_count/!d;s/:[ \t]*\([0-9]*\).*/ \1/;s/^/ /' "$EJABBERD_CONFIG_PATH")\ 92 | $(sed '/^log_rotate_date/!d;s/:[ \t]*\(.[^ ]*\).*/ \1/;s/^/ /' "$EJABBERD_CONFIG_PATH")" 93 | [ -n "$EJABBERD_OPTS" ] && EJABBERD_OPTS="-ejabberd $EJABBERD_OPTS" 94 | EJABBERD_OPTS="-mnesia dir \"$SPOOL_DIR\" $MNESIA_OPTIONS $EJABBERD_OPTS -s ejabberd" 95 | 96 | # export global variables 97 | export EJABBERD_CONFIG_PATH 98 | export EJABBERD_LOG_PATH 99 | export EJABBERD_DOC_PATH 100 | export EJABBERD_PID_PATH 101 | export ERL_CRASH_DUMP 102 | export ERL_EPMD_ADDRESS 103 | export ERL_INETRC 104 | export ERL_MAX_PORTS 105 | export ERL_MAX_ETS_TABLES 106 | export CONTRIB_MODULES_PATH 107 | export CONTRIB_MODULES_CONF_DIR 108 | export ERL_LIBS 109 | 110 | # export dynamic library path 111 | case $(uname -m) in 112 | i[3456]86) cpu="x86" ;; 113 | i86pc) cpu="x86" ;; 114 | armv7*) cpu="armhf" ;; 115 | *) cpu=$(uname -m | tr A-Z a-z) ;; 116 | esac 117 | os=$(uname -s | tr A-Z a-z) 118 | export LD_FALLBACK_LIBRARY_PATH="$SCRIPT_DIR"/lib/${os}-${cpu} 119 | export DYLD_FALLBACK_LIBRARY_PATH="$LD_FALLBACK_LIBRARY_PATH" 120 | 121 | # run command either directly or via su $INSTALLUSER 122 | exec_cmd() 123 | { 124 | case $EXEC_CMD in 125 | as_install_user) su -s /bin/sh -c '"$0" "$@"' "$INSTALLUSER" -- "$@" ;; 126 | as_current_user) "$@" ;; 127 | esac 128 | } 129 | exec_erl() 130 | { 131 | NODE=$1; shift 132 | exec_cmd "$ERL" ${S:--}name "$NODE" $ERLANG_OPTS "$@" 133 | } 134 | exec_iex() 135 | { 136 | NODE=$1; shift 137 | exec_cmd "$IEX" -${S:--}name "$NODE" --erl "$ERLANG_OPTS" "$@" 138 | } 139 | 140 | # usage 141 | debugwarning() 142 | { 143 | if [ "$EJABBERD_BYPASS_WARNINGS" != "true" ] ; then 144 | echo "--------------------------------------------------------------------" 145 | echo "" 146 | echo "IMPORTANT: we will attempt to attach an INTERACTIVE shell" 147 | echo "to an already running ejabberd node." 148 | echo "If an ERROR is printed, it means the connection was not successful." 149 | echo "You can interact with the ejabberd node if you know how to use it." 150 | echo "Please be extremely cautious with your actions," 151 | echo "and exit immediately if you are not completely sure." 152 | echo "" 153 | echo "To detach this shell from ejabberd, press:" 154 | echo " control+c, control+c" 155 | echo "" 156 | echo "--------------------------------------------------------------------" 157 | echo "To bypass permanently this warning, add to ejabberdctl.cfg the line:" 158 | echo " EJABBERD_BYPASS_WARNINGS=true" 159 | echo "Press return to continue" 160 | read -r input 161 | echo "" 162 | fi 163 | } 164 | 165 | livewarning() 166 | { 167 | if [ "$EJABBERD_BYPASS_WARNINGS" != "true" ] ; then 168 | echo "--------------------------------------------------------------------" 169 | echo "" 170 | echo "IMPORTANT: ejabberd is going to start in LIVE (interactive) mode." 171 | echo "All log messages will be shown in the command shell." 172 | echo "You can interact with the ejabberd node if you know how to use it." 173 | echo "Please be extremely cautious with your actions," 174 | echo "and exit immediately if you are not completely sure." 175 | echo "" 176 | echo "To exit this LIVE mode and stop ejabberd, press:" 177 | echo " q(). and press the Enter key" 178 | echo "" 179 | echo "--------------------------------------------------------------------" 180 | echo "To bypass permanently this warning, add to ejabberdctl.cfg the line:" 181 | echo " EJABBERD_BYPASS_WARNINGS=true" 182 | echo "Press return to continue" 183 | read -r input 184 | echo "" 185 | fi 186 | } 187 | 188 | help() 189 | { 190 | echo "" 191 | echo "Commands to start an ejabberd node:" 192 | echo " start Start an ejabberd node in server mode" 193 | echo " debug Attach an interactive Erlang shell to a running ejabberd node" 194 | echo " iexdebug Attach an interactive Elixir shell to a running ejabberd node" 195 | echo " live Start an ejabberd node in live (interactive) mode" 196 | echo " iexlive Start an ejabberd node in live (interactive) mode, within an Elixir shell" 197 | echo " foreground Start an ejabberd node in server mode (attached)" 198 | echo "" 199 | echo "Optional parameters when starting an ejabberd node:" 200 | echo " --config-dir dir Config ejabberd: $ETC_DIR" 201 | echo " --config file Config ejabberd: $EJABBERD_CONFIG_PATH" 202 | echo " --ctl-config file Config ejabberdctl: $EJABBERDCTL_CONFIG_PATH" 203 | echo " --logs dir Directory for logs: $LOGS_DIR" 204 | echo " --spool dir Database spool dir: $SPOOL_DIR" 205 | echo " --node nodename ejabberd node name: $ERLANG_NODE" 206 | echo "" 207 | } 208 | 209 | # dynamic node name helper 210 | uid() 211 | { 212 | uuid=$(uuidgen 2>/dev/null) 213 | [ -z "$uuid" ] && [ -f /proc/sys/kernel/random/uuid ] && uuid=$(cat /proc/sys/kernel/random/uuid) 214 | [ -z "$uuid" ] && uuid=$(printf "%X" "${RANDOM:-$$}$(date +%M%S)") 215 | uuid=${uuid%%-*} 216 | [ $# -eq 0 ] && echo "${uuid}-${ERLANG_NODE}" 217 | [ $# -eq 1 ] && echo "${uuid}-${1}-${ERLANG_NODE}" 218 | [ $# -eq 2 ] && echo "${uuid}-${1}@${2}" 219 | } 220 | 221 | # stop epmd if there is no other running node 222 | stop_epmd() 223 | { 224 | "$EPMD" -names 2>/dev/null | grep -q name || "$EPMD" -kill >/dev/null 225 | } 226 | 227 | # make sure node not already running and node name unregistered 228 | # if all ok, ensure runtime directory exists and make it current directory 229 | check_start() 230 | { 231 | "$EPMD" -names 2>/dev/null | grep -q " ${ERLANG_NODE%@*} " && { 232 | pgrep -f "$ERLANG_NODE" >/dev/null && { 233 | echo "ERROR: The ejabberd node '$ERLANG_NODE' is already running." 234 | exit 4 235 | } 236 | pgrep beam >/dev/null && { 237 | echo "ERROR: The ejabberd node '$ERLANG_NODE' is registered," 238 | echo " but no related beam process has been found." 239 | echo "Shutdown all other erlang nodes, and call 'epmd -kill'." 240 | exit 5 241 | } 242 | "$EPMD" -kill >/dev/null 243 | } 244 | if [ -f "$FILE" ]; then 245 | echo "Unable to start. Start XabberServerWebUI first." 246 | exit 0 247 | fi 248 | 249 | } 250 | 251 | # allow sync calls 252 | wait_status() 253 | { 254 | # args: status try delay 255 | # return: 0 OK, 1 KO 256 | timeout="$2" 257 | status=4 258 | while [ "$status" -ne "$1" ] ; do 259 | sleep "$3" 260 | timeout=$((timeout - 1)) 261 | if [ $timeout -eq 0 ] ; then 262 | status="$1" 263 | else 264 | exec_erl "$(uid ctl)" -hidden -noinput -s ejabberd_ctl \ 265 | -extra "$ERLANG_NODE" $NO_TIMEOUT status > /dev/null 266 | status="$?" 267 | fi 268 | done 269 | [ $timeout -gt 0 ] 270 | } 271 | 272 | # ensure we can change current directory to SPOOL_DIR 273 | [ -d "$SPOOL_DIR" ] || exec_cmd mkdir -p "$SPOOL_DIR" 274 | cd "$SPOOL_DIR" || { 275 | echo "ERROR: can not access directory $SPOOL_DIR" 276 | exit 6 277 | } 278 | 279 | # main 280 | case $1 in 281 | start) 282 | check_start 283 | exec_erl "$ERLANG_NODE" $EJABBERD_OPTS -detached 284 | ;; 285 | foreground) 286 | check_start 287 | exec_erl "$ERLANG_NODE" $EJABBERD_OPTS -noinput 288 | ;; 289 | live) 290 | livewarning 291 | check_start 292 | exec_erl "$ERLANG_NODE" $EJABBERD_OPTS 293 | ;; 294 | debug) 295 | debugwarning 296 | exec_erl "$(uid debug)" -hidden -remsh "$ERLANG_NODE" 297 | ;; 298 | etop) 299 | exec_erl "$(uid top)" -hidden -node "$ERLANG_NODE" -s etop \ 300 | -s erlang halt -output text 301 | ;; 302 | iexdebug) 303 | debugwarning 304 | exec_iex "$(uid debug)" --remsh "$ERLANG_NODE" 305 | ;; 306 | iexlive) 307 | livewarning 308 | exec_iex "$ERLANG_NODE" --erl "$EJABBERD_OPTS" --app ejabberd 309 | ;; 310 | ping) 311 | PEER=${2:-$ERLANG_NODE} 312 | [ "$PEER" = "${PEER%.*}" ] && PS="-s" 313 | exec_cmd "$ERL" ${PS:--}name "$(uid ping "$(hostname $PS)")" $ERLANG_OPTS \ 314 | -noinput -hidden -eval 'io:format("~p~n",[net_adm:ping('"'$PEER'"')])' \ 315 | -s erlang halt -output text 316 | ;; 317 | started) 318 | wait_status 0 30 2 # wait 30x2s before timeout 319 | ;; 320 | stopped) 321 | wait_status 3 30 2 && stop_epmd # wait 30x2s before timeout 322 | ;; 323 | *) 324 | exec_erl "$(uid ctl)" -hidden -noinput -s ejabberd_ctl \ 325 | -extra "$ERLANG_NODE" $NO_TIMEOUT "$@" 326 | result=$? 327 | case $result in 328 | 2|3) help;; 329 | *) :;; 330 | esac 331 | exit $result 332 | ;; 333 | esac 334 | -------------------------------------------------------------------------------- /xabber-server-files/pg.old.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- ejabberd, Copyright (C) 2002-2017 ProcessOne 3 | -- 4 | -- This program is free software; you can redistribute it and/or 5 | -- modify it under the terms of the GNU General Public License as 6 | -- published by the Free Software Foundation; either version 2 of the 7 | -- License, or (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | -- General Public License for more details. 13 | -- 14 | -- You should have received a copy of the GNU General Public License along 15 | -- with this program; if not, write to the Free Software Foundation, Inc., 16 | -- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | -- 18 | 19 | CREATE TABLE users ( 20 | username text PRIMARY KEY, 21 | "password" text NOT NULL, 22 | serverkey text NOT NULL DEFAULT '', 23 | salt text NOT NULL DEFAULT '', 24 | iterationcount integer NOT NULL DEFAULT 0, 25 | created_at TIMESTAMP NOT NULL DEFAULT now() 26 | ); 27 | 28 | -- Add support for SCRAM auth to a database created before ejabberd 16.03: 29 | -- ALTER TABLE users ADD COLUMN serverkey text NOT NULL DEFAULT ''; 30 | -- ALTER TABLE users ADD COLUMN salt text NOT NULL DEFAULT ''; 31 | -- ALTER TABLE users ADD COLUMN iterationcount integer NOT NULL DEFAULT 0; 32 | 33 | CREATE TABLE last ( 34 | username text PRIMARY KEY, 35 | seconds text NOT NULL, 36 | state text NOT NULL 37 | ); 38 | 39 | 40 | CREATE TABLE rosterusers ( 41 | username text NOT NULL, 42 | jid text NOT NULL, 43 | nick text NOT NULL, 44 | subscription character(1) NOT NULL, 45 | ask character(1) NOT NULL, 46 | askmessage text NOT NULL, 47 | server character(1) NOT NULL, 48 | subscribe text NOT NULL, 49 | "type" text, 50 | created_at TIMESTAMP NOT NULL DEFAULT now() 51 | ); 52 | 53 | CREATE UNIQUE INDEX i_rosteru_user_jid ON rosterusers USING btree (username, jid); 54 | CREATE INDEX i_rosteru_username ON rosterusers USING btree (username); 55 | CREATE INDEX i_rosteru_jid ON rosterusers USING btree (jid); 56 | 57 | 58 | CREATE TABLE rostergroups ( 59 | username text NOT NULL, 60 | jid text NOT NULL, 61 | grp text NOT NULL 62 | ); 63 | 64 | CREATE INDEX pk_rosterg_user_jid ON rostergroups USING btree (username, jid); 65 | 66 | CREATE TABLE sr_group ( 67 | name text NOT NULL, 68 | opts text NOT NULL, 69 | created_at TIMESTAMP NOT NULL DEFAULT now() 70 | ); 71 | 72 | CREATE TABLE sr_user ( 73 | jid text NOT NULL, 74 | grp text NOT NULL, 75 | created_at TIMESTAMP NOT NULL DEFAULT now() 76 | ); 77 | 78 | CREATE UNIQUE INDEX i_sr_user_jid_grp ON sr_user USING btree (jid, grp); 79 | CREATE INDEX i_sr_user_jid ON sr_user USING btree (jid); 80 | CREATE INDEX i_sr_user_grp ON sr_user USING btree (grp); 81 | 82 | CREATE TABLE spool ( 83 | username text NOT NULL, 84 | xml text NOT NULL, 85 | seq SERIAL, 86 | created_at TIMESTAMP NOT NULL DEFAULT now() 87 | ); 88 | 89 | CREATE INDEX i_despool ON spool USING btree (username); 90 | 91 | CREATE TABLE archive ( 92 | username text NOT NULL, 93 | timestamp BIGINT NOT NULL, 94 | peer text NOT NULL, 95 | bare_peer text NOT NULL, 96 | xml text NOT NULL, 97 | txt text, 98 | id SERIAL, 99 | kind text, 100 | nick text, 101 | created_at TIMESTAMP NOT NULL DEFAULT now() 102 | ); 103 | 104 | CREATE INDEX i_username_timestamp ON archive USING btree (username, timestamp); 105 | CREATE INDEX i_username_peer ON archive USING btree (username, peer); 106 | CREATE INDEX i_username_bare_peer ON archive USING btree (username, bare_peer); 107 | CREATE INDEX i_timestamp ON archive USING btree (timestamp); 108 | 109 | CREATE TABLE archive_prefs ( 110 | username text NOT NULL PRIMARY KEY, 111 | def text NOT NULL, 112 | always text NOT NULL, 113 | never text NOT NULL, 114 | created_at TIMESTAMP NOT NULL DEFAULT now() 115 | ); 116 | 117 | CREATE TABLE vcard ( 118 | username text PRIMARY KEY, 119 | vcard text NOT NULL, 120 | created_at TIMESTAMP NOT NULL DEFAULT now() 121 | ); 122 | 123 | CREATE TABLE vcard_search ( 124 | username text NOT NULL, 125 | lusername text PRIMARY KEY, 126 | fn text NOT NULL, 127 | lfn text NOT NULL, 128 | family text NOT NULL, 129 | lfamily text NOT NULL, 130 | given text NOT NULL, 131 | lgiven text NOT NULL, 132 | middle text NOT NULL, 133 | lmiddle text NOT NULL, 134 | nickname text NOT NULL, 135 | lnickname text NOT NULL, 136 | bday text NOT NULL, 137 | lbday text NOT NULL, 138 | ctry text NOT NULL, 139 | lctry text NOT NULL, 140 | locality text NOT NULL, 141 | llocality text NOT NULL, 142 | email text NOT NULL, 143 | lemail text NOT NULL, 144 | orgname text NOT NULL, 145 | lorgname text NOT NULL, 146 | orgunit text NOT NULL, 147 | lorgunit text NOT NULL 148 | ); 149 | 150 | CREATE INDEX i_vcard_search_lfn ON vcard_search(lfn); 151 | CREATE INDEX i_vcard_search_lfamily ON vcard_search(lfamily); 152 | CREATE INDEX i_vcard_search_lgiven ON vcard_search(lgiven); 153 | CREATE INDEX i_vcard_search_lmiddle ON vcard_search(lmiddle); 154 | CREATE INDEX i_vcard_search_lnickname ON vcard_search(lnickname); 155 | CREATE INDEX i_vcard_search_lbday ON vcard_search(lbday); 156 | CREATE INDEX i_vcard_search_lctry ON vcard_search(lctry); 157 | CREATE INDEX i_vcard_search_llocality ON vcard_search(llocality); 158 | CREATE INDEX i_vcard_search_lemail ON vcard_search(lemail); 159 | CREATE INDEX i_vcard_search_lorgname ON vcard_search(lorgname); 160 | CREATE INDEX i_vcard_search_lorgunit ON vcard_search(lorgunit); 161 | 162 | CREATE TABLE privacy_default_list ( 163 | username text PRIMARY KEY, 164 | name text NOT NULL 165 | ); 166 | 167 | CREATE TABLE privacy_list ( 168 | username text NOT NULL, 169 | name text NOT NULL, 170 | id SERIAL UNIQUE, 171 | created_at TIMESTAMP NOT NULL DEFAULT now() 172 | ); 173 | 174 | CREATE INDEX i_privacy_list_username ON privacy_list USING btree (username); 175 | CREATE UNIQUE INDEX i_privacy_list_username_name ON privacy_list USING btree (username, name); 176 | 177 | CREATE TABLE privacy_list_data ( 178 | id bigint REFERENCES privacy_list(id) ON DELETE CASCADE, 179 | t character(1) NOT NULL, 180 | value text NOT NULL, 181 | action character(1) NOT NULL, 182 | ord NUMERIC NOT NULL, 183 | match_all boolean NOT NULL, 184 | match_iq boolean NOT NULL, 185 | match_message boolean NOT NULL, 186 | match_presence_in boolean NOT NULL, 187 | match_presence_out boolean NOT NULL 188 | ); 189 | 190 | CREATE INDEX i_privacy_list_data_id ON privacy_list_data USING btree (id); 191 | 192 | CREATE TABLE private_storage ( 193 | username text NOT NULL, 194 | namespace text NOT NULL, 195 | data text NOT NULL, 196 | created_at TIMESTAMP NOT NULL DEFAULT now() 197 | ); 198 | 199 | CREATE INDEX i_private_storage_username ON private_storage USING btree (username); 200 | CREATE UNIQUE INDEX i_private_storage_username_namespace ON private_storage USING btree (username, namespace); 201 | 202 | 203 | CREATE TABLE roster_version ( 204 | username text PRIMARY KEY, 205 | version text NOT NULL 206 | ); 207 | 208 | -- To update from 0.9.8: 209 | -- CREATE SEQUENCE spool_seq_seq; 210 | -- ALTER TABLE spool ADD COLUMN seq integer; 211 | -- ALTER TABLE spool ALTER COLUMN seq SET DEFAULT nextval('spool_seq_seq'); 212 | -- UPDATE spool SET seq = DEFAULT; 213 | -- ALTER TABLE spool ALTER COLUMN seq SET NOT NULL; 214 | 215 | -- To update from 1.x: 216 | -- ALTER TABLE rosterusers ADD COLUMN askmessage text; 217 | -- UPDATE rosterusers SET askmessage = ''; 218 | -- ALTER TABLE rosterusers ALTER COLUMN askmessage SET NOT NULL; 219 | 220 | CREATE TABLE pubsub_node ( 221 | host text NOT NULL, 222 | node text NOT NULL, 223 | parent text NOT NULL DEFAULT '', 224 | plugin text NOT NULL, 225 | nodeid SERIAL UNIQUE 226 | ); 227 | CREATE INDEX i_pubsub_node_parent ON pubsub_node USING btree (parent); 228 | CREATE UNIQUE INDEX i_pubsub_node_tuple ON pubsub_node USING btree (host, node); 229 | 230 | CREATE TABLE pubsub_node_option ( 231 | nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE, 232 | name text NOT NULL, 233 | val text NOT NULL 234 | ); 235 | CREATE INDEX i_pubsub_node_option_nodeid ON pubsub_node_option USING btree (nodeid); 236 | 237 | CREATE TABLE pubsub_node_owner ( 238 | nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE, 239 | owner text NOT NULL 240 | ); 241 | CREATE INDEX i_pubsub_node_owner_nodeid ON pubsub_node_owner USING btree (nodeid); 242 | 243 | CREATE TABLE pubsub_state ( 244 | nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE, 245 | jid text NOT NULL, 246 | affiliation character(1), 247 | subscriptions text NOT NULL DEFAULT '', 248 | stateid SERIAL UNIQUE 249 | ); 250 | CREATE INDEX i_pubsub_state_jid ON pubsub_state USING btree (jid); 251 | CREATE UNIQUE INDEX i_pubsub_state_tuple ON pubsub_state USING btree (nodeid, jid); 252 | 253 | CREATE TABLE pubsub_item ( 254 | nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE, 255 | itemid text NOT NULL, 256 | publisher text NOT NULL, 257 | creation text NOT NULL, 258 | modification text NOT NULL, 259 | payload text NOT NULL DEFAULT '' 260 | ); 261 | CREATE INDEX i_pubsub_item_itemid ON pubsub_item USING btree (itemid); 262 | CREATE UNIQUE INDEX i_pubsub_item_tuple ON pubsub_item USING btree (nodeid, itemid); 263 | 264 | CREATE TABLE pubsub_subscription_opt ( 265 | subid text NOT NULL, 266 | opt_name varchar(32), 267 | opt_value text NOT NULL 268 | ); 269 | CREATE UNIQUE INDEX i_pubsub_subscription_opt ON pubsub_subscription_opt USING btree (subid, opt_name); 270 | 271 | CREATE TABLE muc_room ( 272 | name text NOT NULL, 273 | host text NOT NULL, 274 | opts text NOT NULL, 275 | created_at TIMESTAMP NOT NULL DEFAULT now() 276 | ); 277 | 278 | CREATE UNIQUE INDEX i_muc_room_name_host ON muc_room USING btree (name, host); 279 | 280 | CREATE TABLE muc_registered ( 281 | jid text NOT NULL, 282 | host text NOT NULL, 283 | nick text NOT NULL, 284 | created_at TIMESTAMP NOT NULL DEFAULT now() 285 | ); 286 | 287 | CREATE INDEX i_muc_registered_nick ON muc_registered USING btree (nick); 288 | CREATE UNIQUE INDEX i_muc_registered_jid_host ON muc_registered USING btree (jid, host); 289 | 290 | CREATE TABLE muc_online_room ( 291 | name text NOT NULL, 292 | host text NOT NULL, 293 | node text NOT NULL, 294 | pid text NOT NULL 295 | ); 296 | 297 | CREATE UNIQUE INDEX i_muc_online_room_name_host ON muc_online_room USING btree (name, host); 298 | 299 | CREATE TABLE muc_online_users ( 300 | username text NOT NULL, 301 | server text NOT NULL, 302 | resource text NOT NULL, 303 | name text NOT NULL, 304 | host text NOT NULL, 305 | node text NOT NULL 306 | ); 307 | 308 | CREATE UNIQUE INDEX i_muc_online_users ON muc_online_users USING btree (username, server, resource, name, host); 309 | CREATE INDEX i_muc_online_users_us ON muc_online_users USING btree (username, server); 310 | 311 | CREATE TABLE muc_room_subscribers ( 312 | room text NOT NULL, 313 | host text NOT NULL, 314 | jid text NOT NULL, 315 | nick text NOT NULL, 316 | nodes text NOT NULL, 317 | created_at TIMESTAMP NOT NULL DEFAULT now() 318 | ); 319 | 320 | CREATE INDEX i_muc_room_subscribers_host_jid ON muc_room_subscribers USING btree (host, jid); 321 | CREATE UNIQUE INDEX i_muc_room_subscribers_host_room_jid ON muc_room_subscribers USING btree (host, room, jid); 322 | 323 | CREATE TABLE irc_custom ( 324 | jid text NOT NULL, 325 | host text NOT NULL, 326 | data text NOT NULL, 327 | created_at TIMESTAMP NOT NULL DEFAULT now() 328 | ); 329 | 330 | CREATE UNIQUE INDEX i_irc_custom_jid_host ON irc_custom USING btree (jid, host); 331 | 332 | CREATE TABLE motd ( 333 | username text PRIMARY KEY, 334 | xml text, 335 | created_at TIMESTAMP NOT NULL DEFAULT now() 336 | ); 337 | 338 | CREATE TABLE caps_features ( 339 | node text NOT NULL, 340 | subnode text NOT NULL, 341 | feature text, 342 | created_at TIMESTAMP NOT NULL DEFAULT now() 343 | ); 344 | 345 | CREATE INDEX i_caps_features_node_subnode ON caps_features USING btree (node, subnode); 346 | 347 | CREATE TABLE sm ( 348 | usec bigint NOT NULL, 349 | pid text NOT NULL, 350 | node text NOT NULL, 351 | username text NOT NULL, 352 | resource text NOT NULL, 353 | priority text NOT NULL, 354 | info text NOT NULL 355 | ); 356 | 357 | CREATE UNIQUE INDEX i_sm_sid ON sm USING btree (usec, pid); 358 | CREATE INDEX i_sm_node ON sm USING btree (node); 359 | CREATE INDEX i_sm_username ON sm USING btree (username); 360 | 361 | CREATE TABLE oauth_token ( 362 | token text NOT NULL, 363 | jid text NOT NULL, 364 | scope text NOT NULL, 365 | expire bigint NOT NULL 366 | ); 367 | 368 | CREATE UNIQUE INDEX i_oauth_token_token ON oauth_token USING btree (token); 369 | 370 | CREATE TABLE route ( 371 | domain text NOT NULL, 372 | server_host text NOT NULL, 373 | node text NOT NULL, 374 | pid text NOT NULL, 375 | local_hint text NOT NULL 376 | ); 377 | 378 | CREATE UNIQUE INDEX i_route ON route USING btree (domain, server_host, node, pid); 379 | CREATE INDEX i_route_domain ON route USING btree (domain); 380 | 381 | CREATE TABLE bosh ( 382 | sid text NOT NULL, 383 | node text NOT NULL, 384 | pid text NOT NULL 385 | ); 386 | 387 | CREATE UNIQUE INDEX i_bosh_sid ON bosh USING btree (sid); 388 | 389 | CREATE TABLE carboncopy ( 390 | username text NOT NULL, 391 | resource text NOT NULL, 392 | namespace text NOT NULL, 393 | node text NOT NULL 394 | ); 395 | 396 | CREATE UNIQUE INDEX i_carboncopy_ur ON carboncopy USING btree (username, resource); 397 | CREATE INDEX i_carboncopy_user ON carboncopy USING btree (username); 398 | 399 | CREATE TABLE proxy65 ( 400 | sid text NOT NULL, 401 | pid_t text NOT NULL, 402 | pid_i text NOT NULL, 403 | node_t text NOT NULL, 404 | node_i text NOT NULL, 405 | jid_i text NOT NULL 406 | ); 407 | 408 | CREATE UNIQUE INDEX i_proxy65_sid ON proxy65 USING btree (sid); 409 | CREATE INDEX i_proxy65_jid ON proxy65 USING btree (jid_i); 410 | 411 | CREATE TABLE push_session ( 412 | username text NOT NULL, 413 | timestamp bigint NOT NULL, 414 | service text NOT NULL, 415 | node text NOT NULL, 416 | xml text NOT NULL 417 | ); 418 | 419 | CREATE UNIQUE INDEX i_push_usn ON push_session USING btree (username, service, node); 420 | CREATE UNIQUE INDEX i_push_ut ON push_session USING btree (username, timestamp); 421 | 422 | ALTER TABLE archive ADD CONSTRAINT unique_timestamp UNIQUE (timestamp); 423 | 424 | CREATE TABLE origin_id ( 425 | id text NOT NULL, 426 | stanza_id BIGINT 427 | UNIQUE 428 | REFERENCES archive (timestamp) ON DELETE CASCADE 429 | ); 430 | 431 | CREATE INDEX i_origin_id ON origin_id USING btree (id); 432 | 433 | CREATE TABLE previous_id ( 434 | id BIGINT 435 | UNIQUE 436 | REFERENCES archive (timestamp) ON DELETE CASCADE, 437 | stanza_id BIGINT 438 | UNIQUE 439 | REFERENCES archive (timestamp) ON DELETE CASCADE 440 | ); 441 | 442 | INSERT INTO previous_id (stanza_id, id) 443 | SELECT * FROM ( 444 | SELECT 445 | current.timestamp AS stanza_id, 446 | ( 447 | SELECT previous.timestamp 448 | FROM archive AS previous 449 | WHERE current.timestamp > previous.timestamp 450 | AND current.username = previous.username 451 | AND current.bare_peer = previous.bare_peer 452 | ORDER BY previous.timestamp DESC 453 | LIMIT 1 454 | ) AS id 455 | FROM archive AS current 456 | ) AS pairs 457 | WHERE pairs.id NOTNULL; 458 | 459 | CREATE TABLE groupchats ( 460 | name text NOT NULL, 461 | localpart text NOT NULL PRIMARY KEY REFERENCES users (username) ON DELETE CASCADE, 462 | jid text NOT NULL UNIQUE, 463 | anonymous text NOT NULL, 464 | searchable text NOT NULL, 465 | model text NOT NULL, 466 | description text, 467 | owner text NOT NULL, 468 | avatar_id text DEFAULT '', 469 | message bigint DEFAULT 0, 470 | contacts text, 471 | domains text 472 | ); 473 | 474 | 475 | CREATE TABLE groupchat_users ( 476 | username text NOT NULL, 477 | role text NOT NULL, 478 | id text NOT NULL, 479 | avatar_id text, 480 | avatar_type text, 481 | avatar_url text, 482 | avatar_size integer not null default 0, 483 | nickname text default '', 484 | parse_vcard timestamp NOT NULL default now(), 485 | parse_avatar text NOT NULL default 'yes', 486 | badge text, 487 | chatgroup text NOT NULL REFERENCES groupchats (jid) ON DELETE CASCADE, 488 | subscription text NOT NULL, 489 | last_seen timestamp NOT NULL default now(), 490 | user_updated_at timestamp NOT NULL default now(), 491 | CONSTRAINT UC_groupchat_users UNIQUE (username,chatgroup), 492 | CONSTRAINT UC_groupchat_users_id UNIQUE (id) 493 | ); 494 | 495 | CREATE TABLE groupchat_present ( 496 | username text NOT NULL, 497 | chatgroup text NOT NULL REFERENCES groupchats (jid) ON DELETE CASCADE, 498 | resource text NOT NULL 499 | ); 500 | 501 | CREATE TABLE groupchat_users_vcard ( 502 | jid text PRIMARY KEY, 503 | givenfamily text, 504 | fn text, 505 | nickname text, 506 | image text, 507 | hash text, 508 | fullupdate text 509 | ); 510 | 511 | CREATE TABLE groupchat_rights ( 512 | name text NOT NULL UNIQUE, 513 | type text NOT NULL, 514 | description text NOT NULL 515 | ); 516 | 517 | 518 | CREATE TABLE groupchat_policy ( 519 | username text NOT NULL, 520 | chatgroup text NOT NULL REFERENCES groupchats (jid) ON DELETE CASCADE, 521 | right_name text NOT NULL REFERENCES groupchat_rights(name), 522 | valid_from timestamp NOT NULL, 523 | valid_until timestamp NOT NULL, 524 | issued_by text NOT NULL, 525 | issued_at timestamp NOT NULL, 526 | CONSTRAINT UC_groupchat_policy UNIQUE (username,chatgroup,right_name) 527 | ); 528 | 529 | INSERT INTO groupchat_rights (name,description,type) values 530 | ('send-messages','Send messages','restriction'), 531 | ('read-messages','Read messages','restriction'), 532 | ('owner','Owner','permission'), 533 | ('restrict-participants','Restrict participants','permission'), 534 | ('block-participants','Block participants','permission'), 535 | ('send-invitations','Send invitations','restriction'), 536 | ('send-audio','Send audio','restriction'), 537 | ('send-images','Send images','restriction'), 538 | ('administrator','Administrator','permission'), 539 | ('change-badges','Change badges','permission'), 540 | ('change-nicknames','Change nicknames','permission'), 541 | ('delete-messages','Delete messages','permission') 542 | ; 543 | 544 | CREATE TABLE groupchat_block ( 545 | chatgroup text NOT NULL REFERENCES groupchats (jid) ON DELETE CASCADE, 546 | blocked text NOT NULL, 547 | type text NOT NULL, 548 | anonim_id text, 549 | issued_by text NOT NULL, 550 | issued_at timestamp NOT NULL, 551 | CONSTRAINT UC_groupchat_block UNIQUE (chatgroup,blocked) 552 | ); 553 | 554 | CREATE TABLE groupchat_log ( 555 | chatgroup text NOT NULL REFERENCES groupchats (jid) ON DELETE CASCADE, 556 | username text NOT NULL, 557 | log_event text NOT NULL, 558 | happend_at timestamp NOT NULL, 559 | CONSTRAINT UC_groupchat_log UNIQUE (username,chatgroup,log_event), 560 | FOREIGN KEY (username,chatgroup) REFERENCES groupchat_users (username,chatgroup) ON DELETE CASCADE 561 | ); 562 | 563 | CREATE TABLE groupchat_users_info( 564 | chatgroup text NOT NULL REFERENCES groupchats (jid) ON DELETE CASCADE, 565 | username text NOT NULL, 566 | nickname text NOT NULL, 567 | avatar text, 568 | CONSTRAINT UC_groupchat_users_info UNIQUE (username,chatgroup,nickname), 569 | FOREIGN KEY (username,chatgroup) REFERENCES groupchat_users (username,chatgroup) ON DELETE CASCADE 570 | ); 571 | 572 | CREATE TABLE groupchat_default_restrictions( 573 | chatgroup text NOT NULL REFERENCES groupchats (jid) ON DELETE CASCADE, 574 | right_name text NOT NULL REFERENCES groupchat_rights(name), 575 | action_time text NOT NULL, 576 | CONSTRAINT UC_groupchat_default_restrictions UNIQUE (chatgroup,right_name) 577 | ); 578 | 579 | CREATE TABLE groupchat_retract( 580 | chatgroup text, 581 | xml text, 582 | version integer, 583 | CONSTRAINT uc_groupchat_versions UNIQUE (chatgroup,xml,version), 584 | FOREIGN KEY (chatgroup) REFERENCES groupchats(jid) ON DELETE CASCADE 585 | ); 586 | 587 | CREATE TABLE message_retract( 588 | username text, 589 | xml text, 590 | version bigint, 591 | CONSTRAINT uc_retract_message_versions UNIQUE (username,xml,version), 592 | FOREIGN KEY (username) REFERENCES users(username) ON DELETE CASCADE 593 | ); 594 | 595 | CREATE TABLE foreign_message_stanza_id( 596 | foreign_username text, 597 | our_username text, 598 | foreign_stanza_id bigint UNIQUE, 599 | our_stanza_id bigint 600 | UNIQUE 601 | REFERENCES archive (timestamp) ON DELETE CASCADE 602 | ); 603 | 604 | CREATE INDEX i_our_origin_id ON foreign_message_stanza_id USING btree (foreign_stanza_id); 605 | 606 | CREATE TABLE xabber_token ( 607 | token text NOT NULL, 608 | token_uid text NOT NULL, 609 | jid text NOT NULL, 610 | device text, 611 | client text, 612 | expire bigint NOT NULL, 613 | ip text DEFAULT ''::text, 614 | last_usage bigint NOT NULL DEFAULT 0 615 | ); 616 | 617 | CREATE UNIQUE INDEX i_xabber_token_token ON xabber_token USING btree (token); 618 | CREATE UNIQUE INDEX i_xabber_token_token_uid ON xabber_token USING btree (token_uid); 619 | 620 | ALTER TABLE sm ADD COLUMN token_uid text; 621 | 622 | CREATE TABLE conversation_metadata( 623 | username text, 624 | conversation text, 625 | type text NOT NULL DEFAULT 'chat', 626 | retract bigint NOT NULL DEFAULT 0, 627 | conversation_thread text NOT NULL DEFAULT '', 628 | read_until text NOT NULL DEFAULT '0', 629 | delivered_until text NOT NULL DEFAULT '0', 630 | displayed_until text NOT NULL DEFAULT '0', 631 | updated_at bigint NOT NULL, 632 | CONSTRAINT uc_conversation_metadata UNIQUE (username,conversation,conversation_thread), 633 | FOREIGN KEY (username) REFERENCES users(username) ON DELETE CASCADE 634 | ); 635 | 636 | 637 | -------------------------------------------------------------------------------- /xabber-server-files/psql_stuff/pg.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- Author Andrey Gagarin 3 | -- Copyright: (C) 2018, Redsolution Inc. 4 | -- XEP-0GGG: Group chats 5 | -- 6 | 7 | CREATE TABLE users ( 8 | username text NOT NULL, 9 | server_host text NOT NULL, 10 | "password" text NOT NULL, 11 | serverkey text NOT NULL DEFAULT '', 12 | salt text NOT NULL DEFAULT '', 13 | iterationcount integer NOT NULL DEFAULT 0, 14 | created_at TIMESTAMP NOT NULL DEFAULT now(), 15 | PRIMARY KEY (server_host, username) 16 | ); 17 | 18 | -- Add support for SCRAM auth to a database created before ejabberd 16.03: 19 | -- ALTER TABLE users ADD COLUMN serverkey text NOT NULL DEFAULT ''; 20 | -- ALTER TABLE users ADD COLUMN salt text NOT NULL DEFAULT ''; 21 | -- ALTER TABLE users ADD COLUMN iterationcount integer NOT NULL DEFAULT 0; 22 | 23 | CREATE TABLE last ( 24 | username text NOT NULL, 25 | server_host text NOT NULL, 26 | seconds text NOT NULL, 27 | state text NOT NULL, 28 | PRIMARY KEY (server_host, username) 29 | ); 30 | 31 | 32 | CREATE TABLE rosterusers ( 33 | username text NOT NULL, 34 | server_host text NOT NULL, 35 | jid text NOT NULL, 36 | nick text NOT NULL, 37 | subscription character(1) NOT NULL, 38 | ask character(1) NOT NULL, 39 | askmessage text NOT NULL, 40 | server character(1) NOT NULL, 41 | subscribe text NOT NULL, 42 | "type" text, 43 | created_at TIMESTAMP NOT NULL DEFAULT now() 44 | ); 45 | 46 | CREATE UNIQUE INDEX i_rosteru_sh_user_jid ON rosterusers USING btree (server_host, username, jid); 47 | CREATE INDEX i_rosteru_sh_username ON rosterusers USING btree (server_host, username); 48 | CREATE INDEX i_rosteru_sh_jid ON rosterusers USING btree (server_host, jid); 49 | 50 | 51 | CREATE TABLE rostergroups ( 52 | username text NOT NULL, 53 | server_host text NOT NULL, 54 | jid text NOT NULL, 55 | grp text NOT NULL 56 | ); 57 | 58 | CREATE INDEX i_rosterg_sh_user_jid ON rostergroups USING btree (server_host, username, jid); 59 | 60 | CREATE TABLE sr_group ( 61 | name text NOT NULL, 62 | server_host text NOT NULL, 63 | opts text NOT NULL, 64 | created_at TIMESTAMP NOT NULL DEFAULT now(), 65 | PRIMARY KEY (server_host, name) 66 | ); 67 | 68 | CREATE TABLE sr_user ( 69 | jid text NOT NULL, 70 | server_host text NOT NULL, 71 | grp text NOT NULL, 72 | created_at TIMESTAMP NOT NULL DEFAULT now(), 73 | PRIMARY KEY (server_host, jid, grp) 74 | ); 75 | 76 | CREATE INDEX i_sr_user_sh_jid ON sr_user USING btree (server_host, jid); 77 | CREATE INDEX i_sr_user_sh_grp ON sr_user USING btree (server_host, grp); 78 | 79 | CREATE TABLE spool ( 80 | username text NOT NULL, 81 | server_host text NOT NULL, 82 | xml text NOT NULL, 83 | seq SERIAL, 84 | created_at TIMESTAMP NOT NULL DEFAULT now() 85 | ); 86 | 87 | CREATE INDEX i_spool_sh_username ON spool USING btree (server_host, username); 88 | 89 | CREATE TABLE archive ( 90 | username text NOT NULL, 91 | server_host text NOT NULL, 92 | timestamp BIGINT NOT NULL, 93 | peer text NOT NULL, 94 | bare_peer text NOT NULL, 95 | xml text NOT NULL, 96 | txt text, 97 | id SERIAL, 98 | kind text, 99 | nick text, 100 | created_at TIMESTAMP NOT NULL DEFAULT now() 101 | ); 102 | 103 | CREATE INDEX i_archive_sh_username_timestamp ON archive USING btree (server_host, username, timestamp); 104 | CREATE INDEX i_archive_sh_username_peer ON archive USING btree (server_host, username, peer); 105 | CREATE INDEX i_archive_sh_username_bare_peer ON archive USING btree (server_host, username, bare_peer); 106 | CREATE INDEX i_archive_sh_timestamp ON archive USING btree (server_host, timestamp); 107 | 108 | CREATE TABLE archive_prefs ( 109 | username text NOT NULL, 110 | server_host text NOT NULL, 111 | def text NOT NULL, 112 | always text NOT NULL, 113 | never text NOT NULL, 114 | created_at TIMESTAMP NOT NULL DEFAULT now(), 115 | PRIMARY KEY (server_host, username) 116 | ); 117 | 118 | CREATE TABLE vcard ( 119 | username text NOT NULL, 120 | server_host text NOT NULL, 121 | vcard text NOT NULL, 122 | created_at TIMESTAMP NOT NULL DEFAULT now(), 123 | PRIMARY KEY (server_host, username) 124 | ); 125 | 126 | CREATE TABLE vcard_search ( 127 | username text NOT NULL, 128 | lusername text NOT NULL, 129 | server_host text NOT NULL, 130 | fn text NOT NULL, 131 | lfn text NOT NULL, 132 | family text NOT NULL, 133 | lfamily text NOT NULL, 134 | given text NOT NULL, 135 | lgiven text NOT NULL, 136 | middle text NOT NULL, 137 | lmiddle text NOT NULL, 138 | nickname text NOT NULL, 139 | lnickname text NOT NULL, 140 | bday text NOT NULL, 141 | lbday text NOT NULL, 142 | ctry text NOT NULL, 143 | lctry text NOT NULL, 144 | locality text NOT NULL, 145 | llocality text NOT NULL, 146 | email text NOT NULL, 147 | lemail text NOT NULL, 148 | orgname text NOT NULL, 149 | lorgname text NOT NULL, 150 | orgunit text NOT NULL, 151 | lorgunit text NOT NULL, 152 | PRIMARY KEY (server_host, username) 153 | ); 154 | 155 | CREATE INDEX i_vcard_search_sh_lfn ON vcard_search(server_host, lfn); 156 | CREATE INDEX i_vcard_search_sh_lfamily ON vcard_search(server_host, lfamily); 157 | CREATE INDEX i_vcard_search_sh_lgiven ON vcard_search(server_host, lgiven); 158 | CREATE INDEX i_vcard_search_sh_lmiddle ON vcard_search(server_host, lmiddle); 159 | CREATE INDEX i_vcard_search_sh_lnickname ON vcard_search(server_host, lnickname); 160 | CREATE INDEX i_vcard_search_sh_lbday ON vcard_search(server_host, lbday); 161 | CREATE INDEX i_vcard_search_sh_lctry ON vcard_search(server_host, lctry); 162 | CREATE INDEX i_vcard_search_sh_llocality ON vcard_search(server_host, llocality); 163 | CREATE INDEX i_vcard_search_sh_lemail ON vcard_search(server_host, lemail); 164 | CREATE INDEX i_vcard_search_sh_lorgname ON vcard_search(server_host, lorgname); 165 | CREATE INDEX i_vcard_search_sh_lorgunit ON vcard_search(server_host, lorgunit); 166 | 167 | CREATE TABLE privacy_default_list ( 168 | username text NOT NULL, 169 | server_host text NOT NULL, 170 | name text NOT NULL, 171 | PRIMARY KEY (server_host, username) 172 | ); 173 | 174 | CREATE TABLE privacy_list ( 175 | username text NOT NULL, 176 | server_host text NOT NULL, 177 | name text NOT NULL, 178 | id SERIAL UNIQUE, 179 | created_at TIMESTAMP NOT NULL DEFAULT now() 180 | ); 181 | 182 | CREATE INDEX i_privacy_list_sh_username ON privacy_list USING btree (server_host, username); 183 | CREATE UNIQUE INDEX i_privacy_list_sh_username_name ON privacy_list USING btree (server_host, username, name); 184 | 185 | CREATE TABLE privacy_list_data ( 186 | id bigint REFERENCES privacy_list(id) ON DELETE CASCADE, 187 | t character(1) NOT NULL, 188 | value text NOT NULL, 189 | action character(1) NOT NULL, 190 | ord NUMERIC NOT NULL, 191 | match_all boolean NOT NULL, 192 | match_iq boolean NOT NULL, 193 | match_message boolean NOT NULL, 194 | match_presence_in boolean NOT NULL, 195 | match_presence_out boolean NOT NULL 196 | ); 197 | 198 | CREATE INDEX i_privacy_list_data_id ON privacy_list_data USING btree (id); 199 | 200 | CREATE TABLE private_storage ( 201 | username text NOT NULL, 202 | server_host text NOT NULL, 203 | namespace text NOT NULL, 204 | data text NOT NULL, 205 | created_at TIMESTAMP NOT NULL DEFAULT now(), 206 | PRIMARY KEY (server_host, username, namespace) 207 | ); 208 | 209 | CREATE INDEX i_private_storage_sh_username ON private_storage USING btree (server_host, username); 210 | 211 | 212 | CREATE TABLE roster_version ( 213 | username text NOT NULL, 214 | server_host text NOT NULL, 215 | version text NOT NULL, 216 | PRIMARY KEY (server_host, username) 217 | ); 218 | 219 | -- To update from 0.9.8: 220 | -- CREATE SEQUENCE spool_seq_seq; 221 | -- ALTER TABLE spool ADD COLUMN seq integer; 222 | -- ALTER TABLE spool ALTER COLUMN seq SET DEFAULT nextval('spool_seq_seq'); 223 | -- UPDATE spool SET seq = DEFAULT; 224 | -- ALTER TABLE spool ALTER COLUMN seq SET NOT NULL; 225 | 226 | -- To update from 1.x: 227 | -- ALTER TABLE rosterusers ADD COLUMN askmessage text; 228 | -- UPDATE rosterusers SET askmessage = ''; 229 | -- ALTER TABLE rosterusers ALTER COLUMN askmessage SET NOT NULL; 230 | 231 | CREATE TABLE pubsub_node ( 232 | host text NOT NULL, 233 | node text NOT NULL, 234 | parent text NOT NULL DEFAULT '', 235 | plugin text NOT NULL, 236 | nodeid SERIAL UNIQUE 237 | ); 238 | CREATE INDEX i_pubsub_node_parent ON pubsub_node USING btree (parent); 239 | CREATE UNIQUE INDEX i_pubsub_node_tuple ON pubsub_node USING btree (host, node); 240 | 241 | CREATE TABLE pubsub_node_option ( 242 | nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE, 243 | name text NOT NULL, 244 | val text NOT NULL 245 | ); 246 | CREATE INDEX i_pubsub_node_option_nodeid ON pubsub_node_option USING btree (nodeid); 247 | 248 | CREATE TABLE pubsub_node_owner ( 249 | nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE, 250 | owner text NOT NULL 251 | ); 252 | CREATE INDEX i_pubsub_node_owner_nodeid ON pubsub_node_owner USING btree (nodeid); 253 | 254 | CREATE TABLE pubsub_state ( 255 | nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE, 256 | jid text NOT NULL, 257 | affiliation character(1), 258 | subscriptions text NOT NULL DEFAULT '', 259 | stateid SERIAL UNIQUE 260 | ); 261 | CREATE INDEX i_pubsub_state_jid ON pubsub_state USING btree (jid); 262 | CREATE UNIQUE INDEX i_pubsub_state_tuple ON pubsub_state USING btree (nodeid, jid); 263 | 264 | CREATE TABLE pubsub_item ( 265 | nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE, 266 | itemid text NOT NULL, 267 | publisher text NOT NULL, 268 | creation text NOT NULL, 269 | modification text NOT NULL, 270 | payload text NOT NULL DEFAULT '' 271 | ); 272 | CREATE INDEX i_pubsub_item_itemid ON pubsub_item USING btree (itemid); 273 | CREATE UNIQUE INDEX i_pubsub_item_tuple ON pubsub_item USING btree (nodeid, itemid); 274 | 275 | CREATE TABLE pubsub_subscription_opt ( 276 | subid text NOT NULL, 277 | opt_name varchar(32), 278 | opt_value text NOT NULL 279 | ); 280 | CREATE UNIQUE INDEX i_pubsub_subscription_opt ON pubsub_subscription_opt USING btree (subid, opt_name); 281 | 282 | CREATE TABLE muc_room ( 283 | name text NOT NULL, 284 | host text NOT NULL, 285 | server_host text NOT NULL, 286 | opts text NOT NULL, 287 | created_at TIMESTAMP NOT NULL DEFAULT now() 288 | ); 289 | 290 | CREATE UNIQUE INDEX i_muc_room_name_host ON muc_room USING btree (name, host); 291 | 292 | CREATE TABLE muc_registered ( 293 | jid text NOT NULL, 294 | host text NOT NULL, 295 | server_host text NOT NULL, 296 | nick text NOT NULL, 297 | created_at TIMESTAMP NOT NULL DEFAULT now() 298 | ); 299 | 300 | CREATE INDEX i_muc_registered_nick ON muc_registered USING btree (nick); 301 | CREATE UNIQUE INDEX i_muc_registered_jid_host ON muc_registered USING btree (jid, host); 302 | 303 | CREATE TABLE muc_online_room ( 304 | name text NOT NULL, 305 | host text NOT NULL, 306 | server_host text NOT NULL, 307 | node text NOT NULL, 308 | pid text NOT NULL 309 | ); 310 | 311 | CREATE UNIQUE INDEX i_muc_online_room_name_host ON muc_online_room USING btree (name, host); 312 | 313 | CREATE TABLE muc_online_users ( 314 | username text NOT NULL, 315 | server text NOT NULL, 316 | resource text NOT NULL, 317 | name text NOT NULL, 318 | host text NOT NULL, 319 | server_host text NOT NULL, 320 | node text NOT NULL 321 | ); 322 | 323 | CREATE UNIQUE INDEX i_muc_online_users ON muc_online_users USING btree (username, server, resource, name, host); 324 | CREATE INDEX i_muc_online_users_us ON muc_online_users USING btree (username, server); 325 | 326 | CREATE TABLE muc_room_subscribers ( 327 | room text NOT NULL, 328 | host text NOT NULL, 329 | jid text NOT NULL, 330 | nick text NOT NULL, 331 | nodes text NOT NULL, 332 | created_at TIMESTAMP NOT NULL DEFAULT now() 333 | ); 334 | 335 | CREATE INDEX i_muc_room_subscribers_host_jid ON muc_room_subscribers USING btree (host, jid); 336 | CREATE UNIQUE INDEX i_muc_room_subscribers_host_room_jid ON muc_room_subscribers USING btree (host, room, jid); 337 | 338 | CREATE TABLE irc_custom ( 339 | jid text NOT NULL, 340 | host text NOT NULL, 341 | server_host text NOT NULL, 342 | data text NOT NULL, 343 | created_at TIMESTAMP NOT NULL DEFAULT now() 344 | ); 345 | 346 | CREATE UNIQUE INDEX i_irc_custom_jid_host ON irc_custom USING btree (jid, host); 347 | 348 | CREATE TABLE motd ( 349 | username text NOT NULL, 350 | server_host text NOT NULL, 351 | xml text, 352 | created_at TIMESTAMP NOT NULL DEFAULT now(), 353 | PRIMARY KEY (server_host, username) 354 | ); 355 | 356 | CREATE TABLE caps_features ( 357 | node text NOT NULL, 358 | subnode text NOT NULL, 359 | feature text, 360 | created_at TIMESTAMP NOT NULL DEFAULT now() 361 | ); 362 | 363 | CREATE INDEX i_caps_features_node_subnode ON caps_features USING btree (node, subnode); 364 | 365 | CREATE TABLE sm ( 366 | usec bigint NOT NULL, 367 | pid text NOT NULL, 368 | node text NOT NULL, 369 | username text NOT NULL, 370 | server_host text NOT NULL, 371 | resource text NOT NULL, 372 | priority text NOT NULL, 373 | info text NOT NULL, 374 | PRIMARY KEY (usec, pid) 375 | ); 376 | 377 | CREATE INDEX i_sm_node ON sm USING btree (node); 378 | CREATE INDEX i_sm_sh_username ON sm USING btree (server_host, username); 379 | 380 | CREATE TABLE oauth_token ( 381 | token text NOT NULL, 382 | jid text NOT NULL, 383 | scope text NOT NULL, 384 | expire bigint NOT NULL 385 | ); 386 | 387 | CREATE UNIQUE INDEX i_oauth_token_token ON oauth_token USING btree (token); 388 | 389 | CREATE TABLE route ( 390 | domain text NOT NULL, 391 | server_host text NOT NULL, 392 | node text NOT NULL, 393 | pid text NOT NULL, 394 | local_hint text NOT NULL 395 | ); 396 | 397 | CREATE UNIQUE INDEX i_route ON route USING btree (domain, server_host, node, pid); 398 | CREATE INDEX i_route_domain ON route USING btree (domain); 399 | 400 | CREATE TABLE bosh ( 401 | sid text NOT NULL, 402 | node text NOT NULL, 403 | pid text NOT NULL 404 | ); 405 | 406 | CREATE UNIQUE INDEX i_bosh_sid ON bosh USING btree (sid); 407 | 408 | CREATE TABLE carboncopy ( 409 | username text NOT NULL, 410 | server_host text NOT NULL, 411 | resource text NOT NULL, 412 | namespace text NOT NULL, 413 | node text NOT NULL, 414 | PRIMARY KEY (server_host, username, resource) 415 | ); 416 | 417 | CREATE INDEX i_carboncopy_sh_user ON carboncopy USING btree (server_host, username); 418 | 419 | CREATE TABLE proxy65 ( 420 | sid text NOT NULL, 421 | pid_t text NOT NULL, 422 | pid_i text NOT NULL, 423 | node_t text NOT NULL, 424 | node_i text NOT NULL, 425 | jid_i text NOT NULL 426 | ); 427 | 428 | CREATE UNIQUE INDEX i_proxy65_sid ON proxy65 USING btree (sid); 429 | CREATE INDEX i_proxy65_jid ON proxy65 USING btree (jid_i); 430 | 431 | CREATE TABLE push_session ( 432 | username text NOT NULL, 433 | server_host text NOT NULL, 434 | timestamp bigint NOT NULL, 435 | service text NOT NULL, 436 | node text NOT NULL, 437 | xml text NOT NULL, 438 | PRIMARY KEY (server_host, username, timestamp) 439 | ); 440 | 441 | CREATE UNIQUE INDEX i_push_session_susn ON push_session USING btree (server_host, username, service, node); 442 | 443 | 444 | CREATE TABLE groupchats ( 445 | name text NOT NULL, 446 | localpart text NOT NULL, 447 | server_host text NOT NULL, 448 | jid text NOT NULL UNIQUE, 449 | anonymous text NOT NULL, 450 | searchable text NOT NULL, 451 | model text NOT NULL, 452 | description text, 453 | owner text NOT NULL, 454 | avatar_id text DEFAULT '', 455 | message bigint DEFAULT 0, 456 | contacts text, 457 | domains text, 458 | parent_chat text DEFAULT '0', 459 | PRIMARY KEY (server_host, localpart) 460 | ); 461 | 462 | 463 | CREATE TABLE groupchat_users ( 464 | username text NOT NULL, 465 | role text NOT NULL, 466 | id text NOT NULL, 467 | avatar_id text, 468 | avatar_type text, 469 | avatar_url text, 470 | avatar_size integer not null default 0, 471 | nickname text default '', 472 | parse_vcard timestamp NOT NULL default now(), 473 | parse_avatar text NOT NULL default 'yes', 474 | badge text, 475 | chatgroup text NOT NULL REFERENCES groupchats (jid) ON DELETE CASCADE, 476 | subscription text NOT NULL, 477 | p2p_state text DEFAULT 'true', 478 | last_seen timestamp NOT NULL default now(), 479 | user_updated_at timestamp NOT NULL default now(), 480 | CONSTRAINT UC_groupchat_users UNIQUE (username,chatgroup), 481 | CONSTRAINT UC_groupchat_users_id UNIQUE (id) 482 | ); 483 | 484 | CREATE TABLE groupchat_present ( 485 | username text NOT NULL, 486 | chatgroup text NOT NULL REFERENCES groupchats (jid) ON DELETE CASCADE, 487 | resource text NOT NULL 488 | ); 489 | 490 | CREATE TABLE groupchat_users_vcard ( 491 | jid text PRIMARY KEY, 492 | givenfamily text, 493 | fn text, 494 | nickname text, 495 | image text, 496 | hash text, 497 | fullupdate text 498 | ); 499 | 500 | CREATE TABLE groupchat_rights ( 501 | name text NOT NULL UNIQUE, 502 | type text NOT NULL, 503 | description text NOT NULL 504 | ); 505 | 506 | 507 | CREATE TABLE groupchat_policy ( 508 | username text NOT NULL, 509 | chatgroup text NOT NULL REFERENCES groupchats (jid) ON DELETE CASCADE, 510 | right_name text NOT NULL REFERENCES groupchat_rights(name), 511 | valid_from timestamp NOT NULL, 512 | valid_until timestamp NOT NULL, 513 | issued_by text NOT NULL, 514 | issued_at timestamp NOT NULL, 515 | CONSTRAINT UC_groupchat_policy UNIQUE (username,chatgroup,right_name) 516 | ); 517 | 518 | INSERT INTO groupchat_rights (name,description,type) values 519 | ('send-messages','Send messages','restriction'), 520 | ('read-messages','Read messages','restriction'), 521 | ('owner','Owner','permission'), 522 | ('restrict-participants','Restrict participants','permission'), 523 | ('block-participants','Block participants','permission'), 524 | ('send-invitations','Send invitations','restriction'), 525 | ('administrator','Administrator','permission'), 526 | ('change-badges','Change badges','permission'), 527 | ('change-nicknames','Change nicknames','permission'), 528 | ('delete-messages','Delete messages','permission') 529 | ; 530 | 531 | CREATE TABLE groupchat_block ( 532 | chatgroup text NOT NULL REFERENCES groupchats (jid) ON DELETE CASCADE, 533 | blocked text NOT NULL, 534 | type text NOT NULL, 535 | anonim_id text, 536 | issued_by text NOT NULL, 537 | issued_at timestamp NOT NULL, 538 | CONSTRAINT UC_groupchat_block UNIQUE (chatgroup,blocked) 539 | ); 540 | 541 | CREATE TABLE groupchat_log ( 542 | chatgroup text NOT NULL REFERENCES groupchats (jid) ON DELETE CASCADE, 543 | username text NOT NULL, 544 | log_event text NOT NULL, 545 | happend_at timestamp NOT NULL, 546 | CONSTRAINT UC_groupchat_log UNIQUE (username,chatgroup,log_event), 547 | FOREIGN KEY (username,chatgroup) REFERENCES groupchat_users (username,chatgroup) ON DELETE CASCADE 548 | ); 549 | 550 | CREATE TABLE groupchat_users_info( 551 | chatgroup text NOT NULL REFERENCES groupchats (jid) ON DELETE CASCADE, 552 | username text NOT NULL, 553 | nickname text NOT NULL, 554 | avatar text, 555 | CONSTRAINT UC_groupchat_users_info UNIQUE (username,chatgroup,nickname), 556 | FOREIGN KEY (username,chatgroup) REFERENCES groupchat_users (username,chatgroup) ON DELETE CASCADE 557 | ); 558 | 559 | CREATE TABLE groupchat_default_restrictions( 560 | chatgroup text NOT NULL REFERENCES groupchats (jid) ON DELETE CASCADE, 561 | right_name text NOT NULL REFERENCES groupchat_rights(name), 562 | action_time text NOT NULL, 563 | CONSTRAINT UC_groupchat_default_restrictions UNIQUE (chatgroup,right_name) 564 | ); 565 | 566 | CREATE TABLE groupchat_retract( 567 | chatgroup text, 568 | xml text, 569 | version integer, 570 | CONSTRAINT uc_groupchat_versions UNIQUE (chatgroup,xml,version), 571 | FOREIGN KEY (chatgroup) REFERENCES groupchats(jid) ON DELETE CASCADE 572 | ); 573 | 574 | CREATE TABLE conversation_metadata( 575 | username text, 576 | server_host text NOT NULL, 577 | conversation text, 578 | type text NOT NULL DEFAULT 'chat', 579 | retract bigint NOT NULL DEFAULT 0, 580 | conversation_thread text NOT NULL DEFAULT '', 581 | read_until text NOT NULL DEFAULT '0', 582 | delivered_until text NOT NULL DEFAULT '0', 583 | displayed_until text NOT NULL DEFAULT '0', 584 | updated_at bigint NOT NULL, 585 | CONSTRAINT uc_conversation_metadata UNIQUE (username,server_host,conversation,conversation_thread) 586 | ); 587 | 588 | ALTER TABLE archive ADD CONSTRAINT unique_timestamp UNIQUE (timestamp, server_host); 589 | 590 | CREATE TABLE origin_id ( 591 | id text NOT NULL, 592 | server_host text NOT NULL, 593 | stanza_id BIGINT, 594 | PRIMARY KEY (server_host, stanza_id), 595 | FOREIGN KEY (server_host, stanza_id) REFERENCES archive (server_host, timestamp) ON DELETE CASCADE 596 | ); 597 | 598 | CREATE INDEX i_origin_id ON origin_id USING btree (id); 599 | 600 | CREATE TABLE previous_id ( 601 | server_host text NOT NULL, 602 | id BIGINT, 603 | stanza_id BIGINT, 604 | PRIMARY KEY (server_host, id), 605 | CONSTRAINT uniq_prev_id UNIQUE (server_host, stanza_id), 606 | FOREIGN KEY (server_host, stanza_id) REFERENCES archive (server_host, timestamp) ON DELETE CASCADE, 607 | FOREIGN KEY (server_host, id) REFERENCES archive (server_host, timestamp) ON DELETE CASCADE 608 | ); 609 | 610 | CREATE TABLE message_retract( 611 | username text, 612 | server_host text NOT NULL, 613 | xml text, 614 | version bigint, 615 | CONSTRAINT uc_retract_message_versions UNIQUE (username,server_host,xml,version) 616 | ); 617 | 618 | CREATE TABLE foreign_message_stanza_id( 619 | server_host text NOT NULL, 620 | foreign_username text, 621 | our_username text, 622 | foreign_stanza_id bigint UNIQUE, 623 | our_stanza_id bigint, 624 | PRIMARY KEY (server_host, our_stanza_id) 625 | ); 626 | 627 | CREATE INDEX i_our_origin_id ON foreign_message_stanza_id USING btree (foreign_stanza_id); 628 | 629 | CREATE TABLE xabber_token ( 630 | token text NOT NULL, 631 | token_uid text NOT NULL, 632 | jid text NOT NULL, 633 | device text, 634 | client text, 635 | expire bigint NOT NULL, 636 | ip text DEFAULT ''::text, 637 | last_usage bigint NOT NULL DEFAULT 0 638 | ); 639 | 640 | CREATE UNIQUE INDEX i_xabber_token_token ON xabber_token USING btree (token); 641 | CREATE UNIQUE INDEX i_xabber_token_token_uid ON xabber_token USING btree (token_uid); 642 | 643 | ALTER TABLE sm ADD COLUMN token_uid text; 644 | 645 | CREATE TABLE special_messages( 646 | username text NOT NULL, 647 | server_host text NOT NULL, 648 | conversation text NOT NULL, 649 | timestamp BIGINT NOT NULL, 650 | type text NOT NULL DEFAULT 'chat', 651 | CONSTRAINT uc_special_message UNIQUE (username,server_host,timestamp) 652 | ); 653 | -------------------------------------------------------------------------------- /xabber-server-files/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ERROR_TEXT=$(tput setaf 1) 3 | SUCCESS_TEXT=$(tput setaf 2) 4 | NORMAL_TEXT=$(tput setaf 255) 5 | BOLD=$(tput bold) 6 | NORMAL=$(tput sgr0) 7 | UNDER=$(tput smul) 8 | NOUNDER=$(tput rmul) 9 | 10 | userexecutor=$( whoami ) 11 | dirowner='' 12 | system=$( uname -m ) 13 | DEFGROUP=$( id -gn ) 14 | XABBERUSER='xabberserver' 15 | XABBERGROUP='xabberserver' 16 | GROUP='' 17 | SUDO='' 18 | installpath='' 19 | systemuser='' 20 | DOMAIN='' 21 | EMAIL='' 22 | DBPASS='' 23 | DBUSER='xabber_server_user' 24 | DB='xabber_server_db' 25 | LOG='/dev/null' 26 | XABBER='' 27 | check=0 28 | 29 | function create_self_signed_cert() { 30 | apt-get install openssl >> $LOG 31 | openssl req -new -x509 -newkey rsa:4096 -days 3650 -nodes -out $installdir/ser.pem -keyout $installdir/ser.pem -subj "/C=US/ST=Oregon/L=Portland/O=Company Name/OU=Org/CN=$DOMAIN" >> $LOG 32 | } 33 | 34 | function create_predifined() { 35 | PRECONFIG="$installdir/xmppserverui/predefined_config.json" 36 | echo "{" > $PRECONFIG 37 | echo " \"virtual_host\": \"$DOMAIN\"," >> $PRECONFIG 38 | echo " \"http_host\": \"$XABBER\"," >> $PRECONFIG 39 | echo " \"db_host\": \"localhost\"," >> $PRECONFIG 40 | echo " \"db_name\": \"$DB\"," >> $PRECONFIG 41 | echo " \"db_user\": \"$DBUSER\"," >> $PRECONFIG 42 | echo " \"db_password\": \"$DBPASS\"" >> $PRECONFIG 43 | echo "}" >> $PRECONFIG 44 | chmod 755 $PRECONFIG 45 | chown $systemuser:"$GROUP" $PRECONFIG 46 | } 47 | 48 | function _spinner() { 49 | # $1 start/stop 50 | # 51 | # on start: $2 display message 52 | # on stop : $2 process exit status 53 | # $3 spinner function pid (supplied from stop_spinner) 54 | 55 | local on_success="OK" 56 | local on_fail="FAIL" 57 | local white="\e[1;37m" 58 | local green="\e[1;32m" 59 | local red="\e[1;31m" 60 | local nc="\e[0m" 61 | 62 | case $1 in 63 | start) 64 | # calculate the column where spinner and status msg will be displayed 65 | let column=$(tput cols)-${#2}-8 66 | # display message and position the cursor in $column column 67 | echo -ne ${2} 68 | printf "%${column}s" 69 | 70 | # start spinner 71 | i=1 72 | sp='\|/-' 73 | delay=${SPINNER_DELAY:-0.15} 74 | 75 | while : 76 | do 77 | printf "\b${sp:i++%${#sp}:1}" 78 | sleep $delay 79 | done 80 | ;; 81 | stop) 82 | if [[ -z ${3} ]]; then 83 | echo "spinner is not running.." 84 | exit 1 85 | fi 86 | 87 | kill $3 > /dev/null 2>&1 88 | 89 | # inform the user uppon success or failure 90 | echo -en "\b[" 91 | if [[ $2 -eq 0 ]]; then 92 | echo -en "${green}${on_success}${nc}" 93 | else 94 | echo -en "${red}${on_fail}${nc}" 95 | fi 96 | echo -e "]" 97 | ;; 98 | *) 99 | echo "invalid argument, try {start/stop}" 100 | exit 1 101 | ;; 102 | esac 103 | } 104 | 105 | function start_spinner { 106 | # $1 : msg to display 107 | _spinner "start" "${1}" & 108 | # set global spinner pid 109 | _sp_pid=$! 110 | disown 111 | } 112 | 113 | function stop_spinner { 114 | # $1 : command exit status 115 | _spinner "stop" $1 $_sp_pid 116 | unset _sp_pid 117 | } 118 | 119 | function printTable() 120 | { 121 | local -r delimiter="${1}" 122 | local -r data="$(removeEmptyLines "${2}")" 123 | 124 | if [[ "${delimiter}" != '' && "$(isEmptyString "${data}")" = 'false' ]] 125 | then 126 | local -r numberOfLines="$(wc -l <<< "${data}")" 127 | 128 | if [[ "${numberOfLines}" -gt '0' ]] 129 | then 130 | local table='' 131 | local i=1 132 | 133 | for ((i = 1; i <= "${numberOfLines}"; i = i + 1)) 134 | do 135 | local line='' 136 | line="$(sed "${i}q;d" <<< "${data}")" 137 | 138 | local numberOfColumns='0' 139 | numberOfColumns="$(awk -F "${delimiter}" '{print NF}' <<< "${line}")" 140 | 141 | # Add Line Delimiter 142 | 143 | if [[ "${i}" -eq '1' ]] 144 | then 145 | table="${table}$(printf '%s#+' "$(repeatString '#+' "${numberOfColumns}")")" 146 | fi 147 | 148 | # Add Header Or Body 149 | 150 | table="${table}\n" 151 | 152 | local j=1 153 | 154 | for ((j = 1; j <= "${numberOfColumns}"; j = j + 1)) 155 | do 156 | table="${table}$(printf '#| %s' "$(cut -d "${delimiter}" -f "${j}" <<< "${line}")")" 157 | done 158 | 159 | table="${table}#|\n" 160 | 161 | # Add Line Delimiter 162 | 163 | if [[ "${i}" -eq '1' ]] || [[ "${numberOfLines}" -gt '1' && "${i}" -eq "${numberOfLines}" ]] 164 | then 165 | table="${table}$(printf '%s#+' "$(repeatString '#+' "${numberOfColumns}")")" 166 | fi 167 | done 168 | 169 | if [[ "$(isEmptyString "${table}")" = 'false' ]] 170 | then 171 | echo -e "${table}" | column -s '#' -t | awk '/^\+/{gsub(" ", "-", $0)}1' 172 | fi 173 | fi 174 | fi 175 | } 176 | 177 | function removeEmptyLines() 178 | { 179 | local -r content="${1}" 180 | 181 | echo -e "${content}" | sed '/^\s*$/d' 182 | } 183 | 184 | function repeatString() 185 | { 186 | local -r string="${1}" 187 | local -r numberToRepeat="${2}" 188 | 189 | if [[ "${string}" != '' && "${numberToRepeat}" =~ ^[1-9][0-9]*$ ]] 190 | then 191 | local -r result="$(printf "%${numberToRepeat}s")" 192 | echo -e "${result// /${string}}" 193 | fi 194 | } 195 | 196 | function isEmptyString() 197 | { 198 | local -r string="${1}" 199 | 200 | if [[ "$(trimString "${string}")" = '' ]] 201 | then 202 | echo 'true' && return 0 203 | fi 204 | 205 | echo 'false' && return 1 206 | } 207 | 208 | function trimString() 209 | { 210 | local -r string="${1}" 211 | 212 | sed 's,^[[:blank:]]*,,' <<< "${string}" | sed 's,[[:blank:]]*$,,' 213 | } 214 | 215 | 216 | function dns_instructions() { 217 | echo "${UNDER}Please ensure, that you configured your DNS correctly:${NOUNDER}" 218 | echo "" 219 | echo "To make XMPP work on your server, you need to set up SRV records for domain $DOMAIN. It will allow XMPP clients to correctly find the location of your server using Domain Name System (DNS). You need to add several types of DNS records to make things work" 220 | echo "" 221 | echo "A record for subdomain $DOMAIN to make server management panel available from the Internet on this address" 222 | echo "" 223 | echo "SRV records to help XMPP clients and servers find your server" 224 | echo "" 225 | echo "${UNDER}A Record${NOUNDER}" 226 | echo "" 227 | for item in ${IPNOW[*]} 228 | do 229 | printf "%20s IN A %s\n" $XABBER $item 230 | done 231 | echo "" 232 | echo "${UNDER}SRV Records${NOUNDER}" 233 | echo "" 234 | printTable ',' "Service,Protocol,Priority,Weight,Port,Target,TTL (seconds)\n_xmpp-client,TCP,10,5,5222,$XABBER,Default\n_xmpp-server,TCP,10,5,5269,$XABBER,Default" 235 | exit 2 236 | } 237 | 238 | 239 | function check_srv() { 240 | XABBER="xabber.$DOMAIN" 241 | IPNOW=$( hostname -I ) 242 | AREC="A record for $XABBER" 243 | SRVClient="SRV record for client" 244 | SRVServer="SRV record for server" 245 | 246 | echo "" 247 | start_spinner "A record for $XABBER" 248 | SERVERIP=$( ./dig +short $XABBER ) 249 | if [[ " ${IPNOW[@]} " =~ " $SERVERIP " && $SERVERIP != "" ]]; then 250 | stop_spinner 0 251 | else 252 | stop_spinner 1 253 | check=1 254 | fi 255 | 256 | start_spinner "SRV record for client" 257 | SRV_CLIENT=$( ./dig +short SRV _xmpp-client._tcp.$DOMAIN | awk '{print $4}' ) 258 | if [[ " ${SRV_CLIENT[@]} " =~ " $XABBER. " && $XABBER != "" ]]; then 259 | stop_spinner 0 260 | else 261 | stop_spinner 1 262 | check=1 263 | fi 264 | 265 | start_spinner "SRV record for server" 266 | SRV_SERVER=$( ./dig +short SRV _xmpp-server._tcp.$DOMAIN | awk '{print $4}' ) 267 | if [[ " ${SRV_SERVER[@]} " =~ " $XABBER. " && $XABBER != "" ]]; then 268 | stop_spinner 0 269 | else 270 | stop_spinner 1 271 | check=1 272 | fi 273 | echo "" 274 | } 275 | 276 | function create_db_user() { 277 | apt-get install -y sudo 278 | start_spinner "Creating user for database" 279 | DBPASS=$( tr -cd '[:alnum:]' < /dev/urandom | fold -w30 | head -n1 ) 280 | sudo -i -u postgres psql -c "create role $DBUSER with password '$DBPASS' LOGIN;" >> $LOG 281 | sudo -i -u postgres psql -c "create database $DB owner $DBUSER;" >> $LOG 282 | stop_spinner $? 283 | } 284 | 285 | function default_install_database() { 286 | start_spinner "Installing PostgreSQL" 287 | apt-get install -y sudo postgresql postgresql-contrib >> $LOG 288 | DBPASS=$( tr -cd '[:alnum:]' < /dev/urandom | fold -w30 | head -n1 ) 289 | sudo -i -u postgres psql -c "create role $DBUSER with password '$DBPASS' LOGIN;" >> $LOG 290 | sudo -i -u postgres psql -c "create database $DB owner $DBUSER;" >> $LOG 291 | stop_spinner $? 292 | } 293 | 294 | function ask_to_install_database() { 295 | set +e 296 | dpkg -l | awk '{print $2}' | grep -e '^postgresql$' && create_db_user || default_install_database 297 | set -e 298 | } 299 | 300 | 301 | function install_cert() { 302 | start_spinner "Installing certificates" 303 | rm $installdir/certs/server.pem >> $LOG 304 | ln -s /etc/letsencrypt/live/$XABBER/* $installdir/certs/ >> $LOG 305 | find /etc/letsencrypt/ -type d -exec chmod 755 {} \; >> $LOG 306 | find /etc/letsencrypt/archive/ -type f -exec chmod 644 {} \; >> $LOG 307 | chown -R $systemuser:"$GROUP" $installdir/certs/ >> $LOG 308 | stop_spinner $? 309 | } 310 | 311 | function get_cert() { 312 | start_spinner "Installing certbot" 313 | apt-get install -y certbot >> $LOG 314 | stop_spinner $? 315 | certbot certonly --standalone --agree-tos -m $EMAIL -d $XABBER 316 | } 317 | 318 | function configure_apache() { 319 | start_spinner "Installing Apache" 320 | apt-get install -y apache2 321 | a2enmod headers proxy proxy_http ssl proxy_wstunnel rewrite 322 | a2dissite 000-default.conf 323 | EXP="s#DOMAIN#$XABBER#g" 324 | sh -c "sed -e $EXP <001-site.conf >/etc/apache2/sites-available/001-site.conf" 325 | sh -c "sed -e $EXP <001-site-ssl.conf >/etc/apache2/sites-available/001-site-ssl.conf" 326 | a2ensite 001-site.conf 327 | a2ensite 001-site-ssl.conf 328 | systemctl restart apache2 329 | stop_spinner $? 330 | } 331 | 332 | function get_email() { 333 | 334 | while [ "$EMAIL" = "" ]; do 335 | if [ -n "$EMAIL" ]; then 336 | echo "" 337 | else 338 | printf "Enter your email for important account notifications from Letsencrypt (e.g. ${BOLD}user@domain.com${NORMAL}): " 339 | read EMAIL 340 | fi 341 | done 342 | 343 | regex="^[a-z0-9!#\$%&'*+/=?^_\`{|}~-]+(\.[a-z0-9!#$%&'*+/=?^_\`{|}~-]+)*@([a-z0-9]([a-z0-9-]*[a-z0-9])?\.)+[a-z0-9]([a-z0-9-]*[a-z0-9])?\$" 344 | 345 | if [[ ! $EMAIL =~ $regex ]] ; then 346 | echo "$EMAIL is not valid" 347 | exit 2 348 | fi 349 | } 350 | 351 | function get_info_and_decide() { 352 | start_spinner "Check system for necessary packages" 353 | apt-get update >> $LOG 354 | apt-get install -y bsdmainutils apt-utils >> $LOG 355 | stop_spinner $? 356 | while [ "$DOMAIN" = "" ]; do 357 | if [ -n "$DOMAIN" ]; then 358 | echo "Check $DOMAIN" 359 | else 360 | echo "" 361 | printf "Enter your domain for Xabber Server (e.g. ${BOLD}example.com${NORMAL} ): " 362 | read DOMAIN 363 | fi 364 | done 365 | check_srv 366 | if [[ $check -eq 0 ]]; then 367 | get_email 368 | quick_install 369 | else 370 | dns_instructions 371 | fi 372 | 373 | } 374 | 375 | function quick_install() { 376 | installpath='/opt/xabberserver' 377 | systemuser=$XABBERUSER 378 | GROUP=$XABBERGROUP 379 | 380 | mkdir -p $installpath 381 | get_cert 382 | configure_apache >> $LOG 383 | ask_to_install_database 384 | copy_to_directory 385 | LOG="$installdir/installation.log" 386 | touch $LOG 387 | chown -R $systemuser:"$GROUP" $LOG 388 | chmod 755 $LOG 389 | install_cert 390 | create_predifined 391 | systemctl enable xabberserver.service 392 | systemctl start xabberserver.service 393 | printf "To continue installation process, open https://%s\n" $XABBER 394 | } 395 | 396 | function createuserfunc() 397 | { 398 | user='' 399 | password='' 400 | superuser='' 401 | superpass='' 402 | while [ "$user" = "" -o "$password" = "" -o "$superuser" = "" -o "$superpass" = ""]; do 403 | 404 | if [ -n "$superuser" ]; then 405 | echo "User set to $user" 406 | else 407 | echo -n "Enter superuser to connect to postgresql (e.g. postgres): " 408 | read user 409 | fi 410 | 411 | if [ -n "$superpass" ]; then 412 | echo "Password set" 413 | else 414 | echo -n "Enter password for superuser to connect to postgresql (e.g. qwerty12345): " 415 | read -s password 416 | echo "" 417 | fi 418 | 419 | if [ -n "$user" ]; then 420 | echo "User set to $user" 421 | else 422 | echo -n "Enter username for a new user (e.g. postgresuser): " 423 | read user 424 | fi 425 | 426 | if [ -n "$password" ]; then 427 | echo "Password set" 428 | else 429 | echo -n "Enter password for a new user (e.g. qwerty12345): " 430 | read -s password 431 | echo "" 432 | fi 433 | 434 | done 435 | cmd="DO \$body\$ BEGIN IF NOT EXISTS (SELECT FROM pg_catalog.pg_user WHERE usename = '$user') THEN CREATE ROLE $user LOGIN PASSWORD '$password'; END IF;END \$body\$;" 436 | 437 | 438 | echo "Connecting to database" 439 | PGPASSWORD=$superpass $installpath/psql -U $superuser -d $base -h $host -c '\l' >/dev/null 2>/dev/null 440 | if [ $? -eq 0 ]; then 441 | 442 | PGPASSWORD=$superpass $installpath/psql -U $superuser -h $host -c "$cmd" 443 | PGPASSWORD=$superpass $installpath/psql -U $superuser -h $host -c "CREATE DATABASE $base OWNER $user;" 444 | PGPASSWORD=$password $installpath/psql -U $user -d $base -h $host -f pg.sql 445 | else 446 | echo "Can't connect to database. Maybe you enter wrong data. Try one more time" 447 | createuserfunc 448 | fi 449 | } 450 | 451 | function auto() 452 | { 453 | host='' 454 | user='' 455 | password='' 456 | base='' 457 | while [ "$host" = "" -o "$base" = "" ]; do 458 | 459 | if [ -n "$host" ]; then 460 | echo "Host set to $host" 461 | else 462 | echo -n "Enter host to connect to postgresql (e.g. localhost): " 463 | read host 464 | fi 465 | 466 | if [ -n "$base" ]; then 467 | echo "Database set to $base" 468 | else 469 | echo -n "Enter database to connect to postgresql (e.g. mydatabase): " 470 | read base 471 | fi 472 | 473 | if [ -n "$user" ]; then 474 | echo "User set to $user" 475 | else 476 | echo -n "Enter username to connect to postgresql (e.g. postgresuser): " 477 | read user 478 | fi 479 | 480 | if [ -n "$password" ]; then 481 | echo "Password set" 482 | else 483 | echo -n "Enter password to connect to postgresql (e.g. qwerty12345): " 484 | read -s password 485 | echo "" 486 | fi 487 | 488 | done 489 | 490 | 491 | echo "Connecting to database" 492 | PGPASSWORD=$password $installpath/psql -U $user -d $base -h $host -c '\l' 493 | if [ $? -eq 0 ]; then 494 | EXP1="s/SERVER/\"$host\"/g" 495 | EXP2="s/DATABASE/\"$base\"/g" 496 | EXP3="s/USERNAME/\"$user\"/g" 497 | EXP4="s/PASSWORD/\"$password\"/g" 498 | $SUDO sh -c "sed -e $EXP1 <$installpath/etc/ejabberd/ejabberd.yml.ORIG1 >$installpath/etc/ejabberd/ejabberd.yml.ORIG2" 499 | $SUDO sh -c "sed -e $EXP2 <$installpath/etc/ejabberd/ejabberd.yml.ORIG2 >$installpath/etc/ejabberd/ejabberd.yml.ORIG3" 500 | $SUDO sh -c "sed -e $EXP3 <$installpath/etc/ejabberd/ejabberd.yml.ORIG3 >$installpath/etc/ejabberd/ejabberd.yml.ORIG4" 501 | $SUDO sh -c "sed -e $EXP4 <$installpath/etc/ejabberd/ejabberd.yml.ORIG4 >$installpath/etc/ejabberd/ejabberd.yml" 502 | $SUDO rm -v $installpath/etc/ejabberd/ejabberd.yml.ORIG* 503 | PGPASSWORD=$password $installpath/psql -U $user -d $base -h $host -f pg.sql 504 | else 505 | echo "Can't connect to database. Maybe you enter wrong data" 506 | createuserfunc 507 | fi 508 | } 509 | 510 | function menu() 511 | { 512 | echo "Start database configuration. Choose next step" 513 | echo "0) Exit installation" 514 | echo "1) Script installation" 515 | echo "2) Manual installation" 516 | choice='' 517 | echo -n "Make your choice : " 518 | read choice 519 | case $choice in 520 | 0) echo "Breaking installation" 521 | exit 1;; 522 | 1) auto;; 523 | 2) echo "Use pg.sql in installation directory" 524 | echo "psql -U user -d database -f /your/path/pg.sql" 525 | ;; 526 | *) echo "Wrong selection" 527 | menu 528 | ;; 529 | esac 530 | } 531 | 532 | function console_install() 533 | { 534 | hostname=$( hostname ) 535 | echo -n "Enter your hostname (e.g. $hostname): " 536 | read hostname 537 | if [ "$hostname" = "" ]; then 538 | hostname=$( hostname ) 539 | fi 540 | echo "Hostname $hostname will be used as default host." 541 | 542 | EXP="s/DEFAULT_HOSTNAME/\"$hostname\"/g" 543 | $SUDO sh -c "sed -e $EXP <$installpath/etc/ejabberd/ejabberd.yml.ORIG0 >$installpath/etc/ejabberd/ejabberd.yml.ORIG1" 544 | 545 | menu 546 | echo "Installation finished" 547 | } 548 | 549 | function print_instructions() 550 | { 551 | IP=$( hostname -I ) 552 | HOSTS=$( hostname -f ) 553 | CERT_FILE=$installdir/certs/server.pem 554 | echo "Welcome to Xabber server." 555 | for item in ${IP[*]} 556 | do 557 | if [ -f $CERT_FILE ] 558 | then 559 | printf "To continue installation process, open https://%s:8000\n" $item 560 | else 561 | printf "To continue installation process, open http://%s:8000\n" $item 562 | fi 563 | done 564 | for hst in ${HOSTS[*]} 565 | do 566 | if [ -f $CERT_FILE ] 567 | then 568 | printf "To continue installation process, open https://%s:8000\n" $hst 569 | else 570 | printf "To continue installation process, open http://%s:8000\n" $hst 571 | fi 572 | done 573 | } 574 | 575 | 576 | function web_install() 577 | { 578 | 579 | if [ -x $installdir/xmppserverui/service.sh ] 580 | then 581 | systemctl enable xabberserver.service 582 | systemctl start xabberserver.service 583 | print_instructions 584 | else 585 | echo "You don't have execute permission. Please check your permissions." 586 | echo "namei -l $installdir" 587 | fi 588 | } 589 | 590 | function installation_menu() 591 | { 592 | echo "Choose next step" 593 | echo "0) Exit installation" 594 | echo "1) Web installation" 595 | echo "2) Console installation" 596 | choice='0' 597 | echo -n "Make your choice : " 598 | read choice 599 | case $choice in 600 | 0) echo "Breaking installation" 601 | exit 1;; 602 | 1) web_install;; 603 | 2) console_install;; 604 | *) echo "Wrong selection" 605 | installation_menu 606 | ;; 607 | esac 608 | } 609 | 610 | function expert_create_user() 611 | { 612 | answer0='' 613 | answer='' 614 | installpath="/opt" 615 | echo -n "Enter your path for installation Please, enter absolute path. [ "$installpath/xabberserver" ] : " 616 | read installpath 617 | lastsymbol=${installpath: -1} 618 | if [ "$lastsymbol" = "/" ]; then 619 | installpath=${installpath%?} 620 | fi 621 | if [ "$installpath" = "" ]; then 622 | installpath="/opt/xabberserver" 623 | fi 624 | 625 | if [ ! -d "$installpath" ]; then 626 | echo -n "There is no such directory. Create a directory please. Do you want to create it? Y/n " 627 | read answer 628 | if [ "$answer" = "yes" -o "$answer" = "y" -o "$answer" = "" ]; then 629 | mkdir -p $installpath 630 | fi 631 | fi 632 | 633 | echo -n "Create special user for xabberserver? Y/n " 634 | read answer0 635 | if [ "$answer0" = "yes" -o "$answer0" = "y" -o "$answer0" = "" ]; then 636 | systemuser=$XABBERUSER 637 | echo -n "Please, enter user for xabberserver. [ $systemuser ] : " 638 | read systemuser 639 | 640 | if [ "$systemuser" = "" ]; then 641 | systemuser=$XABBERUSER 642 | fi 643 | 644 | GROUP=$XABBERGROUP 645 | echo -n "Please, enter group for xabberserver. [ $GROUP ] : " 646 | read GROUP 647 | if [ "$GROUP" = "" ]; then 648 | GROUP=$XABBERGROUP 649 | fi 650 | 651 | else 652 | systemuser=$USER 653 | GROUP=$DEFGROUP 654 | fi 655 | copy_to_directory 656 | web_install 657 | } 658 | 659 | function install_regime() 660 | { 661 | echo "Select the appropriate installation type:" 662 | echo "1) Quick ( ${BOLD}Use only on fresh installed system!${NORMAL} )" 663 | echo "2) Advanced" 664 | echo "0) Exit" 665 | choice='' 666 | echo -n "Make your choice : " 667 | read choice 668 | case $choice in 669 | 0) echo "Breaking installation" 670 | exit 1;; 671 | 1) get_info_and_decide;; 672 | 2) expert_create_user;; 673 | *) echo "Wrong selection" 674 | install_regime 675 | ;; 676 | esac 677 | } 678 | 679 | function copy_to_directory() 680 | { 681 | if ! id -u $systemuser > /dev/null 2>&1; then 682 | useradd -rU $systemuser -d $installpath -s /bin/bash 683 | fi 684 | 685 | if ! getent group "$GROUP" > /dev/null 2>&1; then 686 | groupadd $GROUP 687 | fi 688 | installdir="$installpath/xabberserver" 689 | mkdir -m 755 -p $installdir 690 | f=$installdir 691 | while [[ $f != / ]]; do chmod 755 "$f"; f=$(dirname "$f"); done; 692 | start_spinner "Installing into $installdir." 693 | cp -rp * $installdir 694 | mkdir -m 755 $installdir/user_images 695 | mkdir -m 755 $installdir/certs 696 | mv $installdir/server.pem $installdir/certs 697 | EXP00="s#INSTALL_PATH#$installdir#g" 698 | EXP01="s#USER#$systemuser#g" 699 | EXP02="s#GROUP#'$GROUP'#g" 700 | EXP03="s#DEBUG=true#DEBUG=false#g" 701 | sh -c "sed -e $EXP00 <$installdir/xabberserver.service0 >$installdir/xabberserver.service1" 702 | sh -c "sed -e $EXP01 <$installdir/xabberserver.service1 >$installdir/xabberserver.service" 703 | sh -c "sed -e $EXP02 <$installdir/xabberserver.service >/etc/systemd/system/xabberserver.service" 704 | sh -c "sed -e $EXP00 <$installdir/xmppserverui/service.sh.template >$installdir/xmppserverui/service.sh.2" 705 | sh -c "sed -e $EXP03 <$installdir/xmppserverui/service.sh.2 >$installdir/xmppserverui/service.sh" 706 | rm $installdir/xmppserverui/service.sh.2 707 | rm $installdir/xmppserverui/service.sh.template 708 | rm $installdir/xabberserver.service 709 | rm $installdir/xabberserver.service1 710 | rm $installdir/xabberserver.service0 711 | rm $installdir/setup.sh 712 | chmod 755 $installdir/xmppserverui/service.sh 713 | chown -R $systemuser:"$GROUP" $installpath 714 | stop_spinner $? 715 | } 716 | 717 | function install_in_home() 718 | { 719 | echo "Installation started" 720 | installpath=$HOME 721 | systemuser=$USER 722 | GROUP=$DEFGROUP 723 | installdir="$installpath/xabberserver" 724 | mkdir -m 755 -p $installdir 725 | echo "Installing into $installdir" 726 | cp -rp * $installdir 727 | mkdir $installdir/user_images 728 | mkdir $installdir/certs 729 | mv $installdir/server.pem $installdir/certs 730 | EXP00="s#INSTALL_PATH#$installdir#g" 731 | EXP03="s#DEBUG=true#DEBUG=false#g" 732 | sh -c "sed -e $EXP00 <$installdir/xmppserverui/service.sh.template >$installdir/xmppserverui/service.sh.2" 733 | sh -c "sed -e $EXP03 <$installdir/xmppserverui/service.sh.2 >$installdir/xmppserverui/service.sh" 734 | rm $installdir/xmppserverui/service.sh.2 735 | rm $installdir/xmppserverui/service.sh.template 736 | rm $installdir/xabberserver.service0 737 | rm $installdir/setup.sh 738 | chmod 755 $installdir/xmppserverui/service.sh 739 | chown -R $systemuser:"$GROUP" $installdir 740 | echo "To start xabberserver use:" 741 | echo "$installdir/xmppserverui/service.sh start" 742 | } 743 | 744 | if [[ !$system -eq "x86_64" ]]; then 745 | echo "Your system arch $system is not supported" 746 | exit 2 747 | fi 748 | cat xabber.text 749 | set -e 750 | if (( $EUID == 0 )); then 751 | install_regime 752 | else 753 | answer3="emp" 754 | while [ "$answer3" != "" -o "$answer3" != "yes" -o "$answer3" != "no" -o "$answer3" != "n" -o "$answer3" != "y" -o "$answer3" != "Y" -o "$answer3" != "YES" -o "$answer3" != "N" -o "$answer3" != "NO" ]; do 755 | if [ "$answer3" = "yes" -o "$answer3" = "y" -o "$answer3" = "" -o "$answer3" = "Y" -o "$answer3" = "YES" ]; then 756 | install_in_home 757 | break 758 | elif [ "$answer3" = "no" -o "$answer3" = "n" -o "$answer3" == "N" -o "$answer3" == "NO" ]; then 759 | exit 1 760 | break 761 | else 762 | echo "Installation started without root privileges. Server will be installed in $HOME/xabberserver. Do you want to continue? [Y/n]" 763 | read answer3 764 | fi 765 | done 766 | 767 | fi 768 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | As a special exception, the authors give permission to link this program 2 | with the OpenSSL library and distribute the resulting binary. 3 | 4 | GNU AFFERO GENERAL PUBLIC LICENSE 5 | Version 3, 19 November 2007 6 | 7 | Copyright (C) 2007 Free Software Foundation, Inc. 8 | Everyone is permitted to copy and distribute verbatim copies 9 | of this license document, but changing it is not allowed. 10 | 11 | Preamble 12 | 13 | The GNU Affero General Public License is a free, copyleft license for 14 | software and other kinds of works, specifically designed to ensure 15 | cooperation with the community in the case of network server software. 16 | 17 | The licenses for most software and other practical works are designed 18 | to take away your freedom to share and change the works. By contrast, 19 | our General Public Licenses are intended to guarantee your freedom to 20 | share and change all versions of a program--to make sure it remains free 21 | software for all its users. 22 | 23 | When we speak of free software, we are referring to freedom, not 24 | price. Our General Public Licenses are designed to make sure that you 25 | have the freedom to distribute copies of free software (and charge for 26 | them if you wish), that you receive source code or can get it if you 27 | want it, that you can change the software or use pieces of it in new 28 | free programs, and that you know you can do these things. 29 | 30 | Developers that use our General Public Licenses protect your rights 31 | with two steps: (1) assert copyright on the software, and (2) offer 32 | you this License which gives you legal permission to copy, distribute 33 | and/or modify the software. 34 | 35 | A secondary benefit of defending all users' freedom is that 36 | improvements made in alternate versions of the program, if they 37 | receive widespread use, become available for other developers to 38 | incorporate. Many developers of free software are heartened and 39 | encouraged by the resulting cooperation. However, in the case of 40 | software used on network servers, this result may fail to come about. 41 | The GNU General Public License permits making a modified version and 42 | letting the public access it on a server without ever releasing its 43 | source code to the public. 44 | 45 | The GNU Affero General Public License is designed specifically to 46 | ensure that, in such cases, the modified source code becomes available 47 | to the community. It requires the operator of a network server to 48 | provide the source code of the modified version running there to the 49 | users of that server. Therefore, public use of a modified version, on 50 | a publicly accessible server, gives the public access to the source 51 | code of the modified version. 52 | 53 | An older license, called the Affero General Public License and 54 | published by Affero, was designed to accomplish similar goals. This is 55 | a different license, not a version of the Affero GPL, but Affero has 56 | released a new version of the Affero GPL which permits relicensing under 57 | this license. 58 | 59 | The precise terms and conditions for copying, distribution and 60 | modification follow. 61 | 62 | TERMS AND CONDITIONS 63 | 64 | 0. Definitions. 65 | 66 | "This License" refers to version 3 of the GNU Affero General Public License. 67 | 68 | "Copyright" also means copyright-like laws that apply to other kinds of 69 | works, such as semiconductor masks. 70 | 71 | "The Program" refers to any copyrightable work licensed under this 72 | License. Each licensee is addressed as "you". "Licensees" and 73 | "recipients" may be individuals or organizations. 74 | 75 | To "modify" a work means to copy from or adapt all or part of the work 76 | in a fashion requiring copyright permission, other than the making of an 77 | exact copy. The resulting work is called a "modified version" of the 78 | earlier work or a work "based on" the earlier work. 79 | 80 | A "covered work" means either the unmodified Program or a work based 81 | on the Program. 82 | 83 | To "propagate" a work means to do anything with it that, without 84 | permission, would make you directly or secondarily liable for 85 | infringement under applicable copyright law, except executing it on a 86 | computer or modifying a private copy. Propagation includes copying, 87 | distribution (with or without modification), making available to the 88 | public, and in some countries other activities as well. 89 | 90 | To "convey" a work means any kind of propagation that enables other 91 | parties to make or receive copies. Mere interaction with a user through 92 | a computer network, with no transfer of a copy, is not conveying. 93 | 94 | An interactive user interface displays "Appropriate Legal Notices" 95 | to the extent that it includes a convenient and prominently visible 96 | feature that (1) displays an appropriate copyright notice, and (2) 97 | tells the user that there is no warranty for the work (except to the 98 | extent that warranties are provided), that licensees may convey the 99 | work under this License, and how to view a copy of this License. If 100 | the interface presents a list of user commands or options, such as a 101 | menu, a prominent item in the list meets this criterion. 102 | 103 | 1. Source Code. 104 | 105 | The "source code" for a work means the preferred form of the work 106 | for making modifications to it. "Object code" means any non-source 107 | form of a work. 108 | 109 | A "Standard Interface" means an interface that either is an official 110 | standard defined by a recognized standards body, or, in the case of 111 | interfaces specified for a particular programming language, one that 112 | is widely used among developers working in that language. 113 | 114 | The "System Libraries" of an executable work include anything, other 115 | than the work as a whole, that (a) is included in the normal form of 116 | packaging a Major Component, but which is not part of that Major 117 | Component, and (b) serves only to enable use of the work with that 118 | Major Component, or to implement a Standard Interface for which an 119 | implementation is available to the public in source code form. A 120 | "Major Component", in this context, means a major essential component 121 | (kernel, window system, and so on) of the specific operating system 122 | (if any) on which the executable work runs, or a compiler used to 123 | produce the work, or an object code interpreter used to run it. 124 | 125 | The "Corresponding Source" for a work in object code form means all 126 | the source code needed to generate, install, and (for an executable 127 | work) run the object code and to modify the work, including scripts to 128 | control those activities. However, it does not include the work's 129 | System Libraries, or general-purpose tools or generally available free 130 | programs which are used unmodified in performing those activities but 131 | which are not part of the work. For example, Corresponding Source 132 | includes interface definition files associated with source files for 133 | the work, and the source code for shared libraries and dynamically 134 | linked subprograms that the work is specifically designed to require, 135 | such as by intimate data communication or control flow between those 136 | subprograms and other parts of the work. 137 | 138 | The Corresponding Source need not include anything that users 139 | can regenerate automatically from other parts of the Corresponding 140 | Source. 141 | 142 | The Corresponding Source for a work in source code form is that 143 | same work. 144 | 145 | 2. Basic Permissions. 146 | 147 | All rights granted under this License are granted for the term of 148 | copyright on the Program, and are irrevocable provided the stated 149 | conditions are met. This License explicitly affirms your unlimited 150 | permission to run the unmodified Program. The output from running a 151 | covered work is covered by this License only if the output, given its 152 | content, constitutes a covered work. This License acknowledges your 153 | rights of fair use or other equivalent, as provided by copyright law. 154 | 155 | You may make, run and propagate covered works that you do not 156 | convey, without conditions so long as your license otherwise remains 157 | in force. You may convey covered works to others for the sole purpose 158 | of having them make modifications exclusively for you, or provide you 159 | with facilities for running those works, provided that you comply with 160 | the terms of this License in conveying all material for which you do 161 | not control copyright. Those thus making or running the covered works 162 | for you must do so exclusively on your behalf, under your direction 163 | and control, on terms that prohibit them from making any copies of 164 | your copyrighted material outside their relationship with you. 165 | 166 | Conveying under any other circumstances is permitted solely under 167 | the conditions stated below. Sublicensing is not allowed; section 10 168 | makes it unnecessary. 169 | 170 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 171 | 172 | No covered work shall be deemed part of an effective technological 173 | measure under any applicable law fulfilling obligations under article 174 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 175 | similar laws prohibiting or restricting circumvention of such 176 | measures. 177 | 178 | When you convey a covered work, you waive any legal power to forbid 179 | circumvention of technological measures to the extent such circumvention 180 | is effected by exercising rights under this License with respect to 181 | the covered work, and you disclaim any intention to limit operation or 182 | modification of the work as a means of enforcing, against the work's 183 | users, your or third parties' legal rights to forbid circumvention of 184 | technological measures. 185 | 186 | 4. Conveying Verbatim Copies. 187 | 188 | You may convey verbatim copies of the Program's source code as you 189 | receive it, in any medium, provided that you conspicuously and 190 | appropriately publish on each copy an appropriate copyright notice; 191 | keep intact all notices stating that this License and any 192 | non-permissive terms added in accord with section 7 apply to the code; 193 | keep intact all notices of the absence of any warranty; and give all 194 | recipients a copy of this License along with the Program. 195 | 196 | You may charge any price or no price for each copy that you convey, 197 | and you may offer support or warranty protection for a fee. 198 | 199 | 5. Conveying Modified Source Versions. 200 | 201 | You may convey a work based on the Program, or the modifications to 202 | produce it from the Program, in the form of source code under the 203 | terms of section 4, provided that you also meet all of these conditions: 204 | 205 | a) The work must carry prominent notices stating that you modified 206 | it, and giving a relevant date. 207 | 208 | b) The work must carry prominent notices stating that it is 209 | released under this License and any conditions added under section 210 | 7. This requirement modifies the requirement in section 4 to 211 | "keep intact all notices". 212 | 213 | c) You must license the entire work, as a whole, under this 214 | License to anyone who comes into possession of a copy. This 215 | License will therefore apply, along with any applicable section 7 216 | additional terms, to the whole of the work, and all its parts, 217 | regardless of how they are packaged. This License gives no 218 | permission to license the work in any other way, but it does not 219 | invalidate such permission if you have separately received it. 220 | 221 | d) If the work has interactive user interfaces, each must display 222 | Appropriate Legal Notices; however, if the Program has interactive 223 | interfaces that do not display Appropriate Legal Notices, your 224 | work need not make them do so. 225 | 226 | A compilation of a covered work with other separate and independent 227 | works, which are not by their nature extensions of the covered work, 228 | and which are not combined with it such as to form a larger program, 229 | in or on a volume of a storage or distribution medium, is called an 230 | "aggregate" if the compilation and its resulting copyright are not 231 | used to limit the access or legal rights of the compilation's users 232 | beyond what the individual works permit. Inclusion of a covered work 233 | in an aggregate does not cause this License to apply to the other 234 | parts of the aggregate. 235 | 236 | 6. Conveying Non-Source Forms. 237 | 238 | You may convey a covered work in object code form under the terms 239 | of sections 4 and 5, provided that you also convey the 240 | machine-readable Corresponding Source under the terms of this License, 241 | in one of these ways: 242 | 243 | a) Convey the object code in, or embodied in, a physical product 244 | (including a physical distribution medium), accompanied by the 245 | Corresponding Source fixed on a durable physical medium 246 | customarily used for software interchange. 247 | 248 | b) Convey the object code in, or embodied in, a physical product 249 | (including a physical distribution medium), accompanied by a 250 | written offer, valid for at least three years and valid for as 251 | long as you offer spare parts or customer support for that product 252 | model, to give anyone who possesses the object code either (1) a 253 | copy of the Corresponding Source for all the software in the 254 | product that is covered by this License, on a durable physical 255 | medium customarily used for software interchange, for a price no 256 | more than your reasonable cost of physically performing this 257 | conveying of source, or (2) access to copy the 258 | Corresponding Source from a network server at no charge. 259 | 260 | c) Convey individual copies of the object code with a copy of the 261 | written offer to provide the Corresponding Source. This 262 | alternative is allowed only occasionally and noncommercially, and 263 | only if you received the object code with such an offer, in accord 264 | with subsection 6b. 265 | 266 | d) Convey the object code by offering access from a designated 267 | place (gratis or for a charge), and offer equivalent access to the 268 | Corresponding Source in the same way through the same place at no 269 | further charge. You need not require recipients to copy the 270 | Corresponding Source along with the object code. If the place to 271 | copy the object code is a network server, the Corresponding Source 272 | may be on a different server (operated by you or a third party) 273 | that supports equivalent copying facilities, provided you maintain 274 | clear directions next to the object code saying where to find the 275 | Corresponding Source. Regardless of what server hosts the 276 | Corresponding Source, you remain obligated to ensure that it is 277 | available for as long as needed to satisfy these requirements. 278 | 279 | e) Convey the object code using peer-to-peer transmission, provided 280 | you inform other peers where the object code and Corresponding 281 | Source of the work are being offered to the general public at no 282 | charge under subsection 6d. 283 | 284 | A separable portion of the object code, whose source code is excluded 285 | from the Corresponding Source as a System Library, need not be 286 | included in conveying the object code work. 287 | 288 | A "User Product" is either (1) a "consumer product", which means any 289 | tangible personal property which is normally used for personal, family, 290 | or household purposes, or (2) anything designed or sold for incorporation 291 | into a dwelling. In determining whether a product is a consumer product, 292 | doubtful cases shall be resolved in favor of coverage. For a particular 293 | product received by a particular user, "normally used" refers to a 294 | typical or common use of that class of product, regardless of the status 295 | of the particular user or of the way in which the particular user 296 | actually uses, or expects or is expected to use, the product. A product 297 | is a consumer product regardless of whether the product has substantial 298 | commercial, industrial or non-consumer uses, unless such uses represent 299 | the only significant mode of use of the product. 300 | 301 | "Installation Information" for a User Product means any methods, 302 | procedures, authorization keys, or other information required to install 303 | and execute modified versions of a covered work in that User Product from 304 | a modified version of its Corresponding Source. The information must 305 | suffice to ensure that the continued functioning of the modified object 306 | code is in no case prevented or interfered with solely because 307 | modification has been made. 308 | 309 | If you convey an object code work under this section in, or with, or 310 | specifically for use in, a User Product, and the conveying occurs as 311 | part of a transaction in which the right of possession and use of the 312 | User Product is transferred to the recipient in perpetuity or for a 313 | fixed term (regardless of how the transaction is characterized), the 314 | Corresponding Source conveyed under this section must be accompanied 315 | by the Installation Information. But this requirement does not apply 316 | if neither you nor any third party retains the ability to install 317 | modified object code on the User Product (for example, the work has 318 | been installed in ROM). 319 | 320 | The requirement to provide Installation Information does not include a 321 | requirement to continue to provide support service, warranty, or updates 322 | for a work that has been modified or installed by the recipient, or for 323 | the User Product in which it has been modified or installed. Access to a 324 | network may be denied when the modification itself materially and 325 | adversely affects the operation of the network or violates the rules and 326 | protocols for communication across the network. 327 | 328 | Corresponding Source conveyed, and Installation Information provided, 329 | in accord with this section must be in a format that is publicly 330 | documented (and with an implementation available to the public in 331 | source code form), and must require no special password or key for 332 | unpacking, reading or copying. 333 | 334 | 7. Additional Terms. 335 | 336 | "Additional permissions" are terms that supplement the terms of this 337 | License by making exceptions from one or more of its conditions. 338 | Additional permissions that are applicable to the entire Program shall 339 | be treated as though they were included in this License, to the extent 340 | that they are valid under applicable law. If additional permissions 341 | apply only to part of the Program, that part may be used separately 342 | under those permissions, but the entire Program remains governed by 343 | this License without regard to the additional permissions. 344 | 345 | When you convey a copy of a covered work, you may at your option 346 | remove any additional permissions from that copy, or from any part of 347 | it. (Additional permissions may be written to require their own 348 | removal in certain cases when you modify the work.) You may place 349 | additional permissions on material, added by you to a covered work, 350 | for which you have or can give appropriate copyright permission. 351 | 352 | Notwithstanding any other provision of this License, for material you 353 | add to a covered work, you may (if authorized by the copyright holders of 354 | that material) supplement the terms of this License with terms: 355 | 356 | a) Disclaiming warranty or limiting liability differently from the 357 | terms of sections 15 and 16 of this License; or 358 | 359 | b) Requiring preservation of specified reasonable legal notices or 360 | author attributions in that material or in the Appropriate Legal 361 | Notices displayed by works containing it; or 362 | 363 | c) Prohibiting misrepresentation of the origin of that material, or 364 | requiring that modified versions of such material be marked in 365 | reasonable ways as different from the original version; or 366 | 367 | d) Limiting the use for publicity purposes of names of licensors or 368 | authors of the material; or 369 | 370 | e) Declining to grant rights under trademark law for use of some 371 | trade names, trademarks, or service marks; or 372 | 373 | f) Requiring indemnification of licensors and authors of that 374 | material by anyone who conveys the material (or modified versions of 375 | it) with contractual assumptions of liability to the recipient, for 376 | any liability that these contractual assumptions directly impose on 377 | those licensors and authors. 378 | 379 | All other non-permissive additional terms are considered "further 380 | restrictions" within the meaning of section 10. If the Program as you 381 | received it, or any part of it, contains a notice stating that it is 382 | governed by this License along with a term that is a further 383 | restriction, you may remove that term. If a license document contains 384 | a further restriction but permits relicensing or conveying under this 385 | License, you may add to a covered work material governed by the terms 386 | of that license document, provided that the further restriction does 387 | not survive such relicensing or conveying. 388 | 389 | If you add terms to a covered work in accord with this section, you 390 | must place, in the relevant source files, a statement of the 391 | additional terms that apply to those files, or a notice indicating 392 | where to find the applicable terms. 393 | 394 | Additional terms, permissive or non-permissive, may be stated in the 395 | form of a separately written license, or stated as exceptions; 396 | the above requirements apply either way. 397 | 398 | 8. Termination. 399 | 400 | You may not propagate or modify a covered work except as expressly 401 | provided under this License. Any attempt otherwise to propagate or 402 | modify it is void, and will automatically terminate your rights under 403 | this License (including any patent licenses granted under the third 404 | paragraph of section 11). 405 | 406 | However, if you cease all violation of this License, then your 407 | license from a particular copyright holder is reinstated (a) 408 | provisionally, unless and until the copyright holder explicitly and 409 | finally terminates your license, and (b) permanently, if the copyright 410 | holder fails to notify you of the violation by some reasonable means 411 | prior to 60 days after the cessation. 412 | 413 | Moreover, your license from a particular copyright holder is 414 | reinstated permanently if the copyright holder notifies you of the 415 | violation by some reasonable means, this is the first time you have 416 | received notice of violation of this License (for any work) from that 417 | copyright holder, and you cure the violation prior to 30 days after 418 | your receipt of the notice. 419 | 420 | Termination of your rights under this section does not terminate the 421 | licenses of parties who have received copies or rights from you under 422 | this License. If your rights have been terminated and not permanently 423 | reinstated, you do not qualify to receive new licenses for the same 424 | material under section 10. 425 | 426 | 9. Acceptance Not Required for Having Copies. 427 | 428 | You are not required to accept this License in order to receive or 429 | run a copy of the Program. Ancillary propagation of a covered work 430 | occurring solely as a consequence of using peer-to-peer transmission 431 | to receive a copy likewise does not require acceptance. However, 432 | nothing other than this License grants you permission to propagate or 433 | modify any covered work. These actions infringe copyright if you do 434 | not accept this License. Therefore, by modifying or propagating a 435 | covered work, you indicate your acceptance of this License to do so. 436 | 437 | 10. Automatic Licensing of Downstream Recipients. 438 | 439 | Each time you convey a covered work, the recipient automatically 440 | receives a license from the original licensors, to run, modify and 441 | propagate that work, subject to this License. You are not responsible 442 | for enforcing compliance by third parties with this License. 443 | 444 | An "entity transaction" is a transaction transferring control of an 445 | organization, or substantially all assets of one, or subdividing an 446 | organization, or merging organizations. If propagation of a covered 447 | work results from an entity transaction, each party to that 448 | transaction who receives a copy of the work also receives whatever 449 | licenses to the work the party's predecessor in interest had or could 450 | give under the previous paragraph, plus a right to possession of the 451 | Corresponding Source of the work from the predecessor in interest, if 452 | the predecessor has it or can get it with reasonable efforts. 453 | 454 | You may not impose any further restrictions on the exercise of the 455 | rights granted or affirmed under this License. For example, you may 456 | not impose a license fee, royalty, or other charge for exercise of 457 | rights granted under this License, and you may not initiate litigation 458 | (including a cross-claim or counterclaim in a lawsuit) alleging that 459 | any patent claim is infringed by making, using, selling, offering for 460 | sale, or importing the Program or any portion of it. 461 | 462 | 11. Patents. 463 | 464 | A "contributor" is a copyright holder who authorizes use under this 465 | License of the Program or a work on which the Program is based. The 466 | work thus licensed is called the contributor's "contributor version". 467 | 468 | A contributor's "essential patent claims" are all patent claims 469 | owned or controlled by the contributor, whether already acquired or 470 | hereafter acquired, that would be infringed by some manner, permitted 471 | by this License, of making, using, or selling its contributor version, 472 | but do not include claims that would be infringed only as a 473 | consequence of further modification of the contributor version. For 474 | purposes of this definition, "control" includes the right to grant 475 | patent sublicenses in a manner consistent with the requirements of 476 | this License. 477 | 478 | Each contributor grants you a non-exclusive, worldwide, royalty-free 479 | patent license under the contributor's essential patent claims, to 480 | make, use, sell, offer for sale, import and otherwise run, modify and 481 | propagate the contents of its contributor version. 482 | 483 | In the following three paragraphs, a "patent license" is any express 484 | agreement or commitment, however denominated, not to enforce a patent 485 | (such as an express permission to practice a patent or covenant not to 486 | sue for patent infringement). To "grant" such a patent license to a 487 | party means to make such an agreement or commitment not to enforce a 488 | patent against the party. 489 | 490 | If you convey a covered work, knowingly relying on a patent license, 491 | and the Corresponding Source of the work is not available for anyone 492 | to copy, free of charge and under the terms of this License, through a 493 | publicly available network server or other readily accessible means, 494 | then you must either (1) cause the Corresponding Source to be so 495 | available, or (2) arrange to deprive yourself of the benefit of the 496 | patent license for this particular work, or (3) arrange, in a manner 497 | consistent with the requirements of this License, to extend the patent 498 | license to downstream recipients. "Knowingly relying" means you have 499 | actual knowledge that, but for the patent license, your conveying the 500 | covered work in a country, or your recipient's use of the covered work 501 | in a country, would infringe one or more identifiable patents in that 502 | country that you have reason to believe are valid. 503 | 504 | If, pursuant to or in connection with a single transaction or 505 | arrangement, you convey, or propagate by procuring conveyance of, a 506 | covered work, and grant a patent license to some of the parties 507 | receiving the covered work authorizing them to use, propagate, modify 508 | or convey a specific copy of the covered work, then the patent license 509 | you grant is automatically extended to all recipients of the covered 510 | work and works based on it. 511 | 512 | A patent license is "discriminatory" if it does not include within 513 | the scope of its coverage, prohibits the exercise of, or is 514 | conditioned on the non-exercise of one or more of the rights that are 515 | specifically granted under this License. You may not convey a covered 516 | work if you are a party to an arrangement with a third party that is 517 | in the business of distributing software, under which you make payment 518 | to the third party based on the extent of your activity of conveying 519 | the work, and under which the third party grants, to any of the 520 | parties who would receive the covered work from you, a discriminatory 521 | patent license (a) in connection with copies of the covered work 522 | conveyed by you (or copies made from those copies), or (b) primarily 523 | for and in connection with specific products or compilations that 524 | contain the covered work, unless you entered into that arrangement, 525 | or that patent license was granted, prior to 28 March 2007. 526 | 527 | Nothing in this License shall be construed as excluding or limiting 528 | any implied license or other defenses to infringement that may 529 | otherwise be available to you under applicable patent law. 530 | 531 | 12. No Surrender of Others' Freedom. 532 | 533 | If conditions are imposed on you (whether by court order, agreement or 534 | otherwise) that contradict the conditions of this License, they do not 535 | excuse you from the conditions of this License. If you cannot convey a 536 | covered work so as to satisfy simultaneously your obligations under this 537 | License and any other pertinent obligations, then as a consequence you may 538 | not convey it at all. For example, if you agree to terms that obligate you 539 | to collect a royalty for further conveying from those to whom you convey 540 | the Program, the only way you could satisfy both those terms and this 541 | License would be to refrain entirely from conveying the Program. 542 | 543 | 13. Remote Network Interaction; Use with the GNU General Public License. 544 | 545 | Notwithstanding any other provision of this License, if you modify the 546 | Program, your modified version must prominently offer all users 547 | interacting with it remotely through a computer network (if your version 548 | supports such interaction) an opportunity to receive the Corresponding 549 | Source of your version by providing access to the Corresponding Source 550 | from a network server at no charge, through some standard or customary 551 | means of facilitating copying of software. This Corresponding Source 552 | shall include the Corresponding Source for any work covered by version 3 553 | of the GNU General Public License that is incorporated pursuant to the 554 | following paragraph. 555 | 556 | Notwithstanding any other provision of this License, you have 557 | permission to link or combine any covered work with a work licensed 558 | under version 3 of the GNU General Public License into a single 559 | combined work, and to convey the resulting work. The terms of this 560 | License will continue to apply to the part which is the covered work, 561 | but the work with which it is combined will remain governed by version 562 | 3 of the GNU General Public License. 563 | 564 | 14. Revised Versions of this License. 565 | 566 | The Free Software Foundation may publish revised and/or new versions of 567 | the GNU Affero General Public License from time to time. Such new versions 568 | will be similar in spirit to the present version, but may differ in detail to 569 | address new problems or concerns. 570 | 571 | Each version is given a distinguishing version number. If the 572 | Program specifies that a certain numbered version of the GNU Affero General 573 | Public License "or any later version" applies to it, you have the 574 | option of following the terms and conditions either of that numbered 575 | version or of any later version published by the Free Software 576 | Foundation. If the Program does not specify a version number of the 577 | GNU Affero General Public License, you may choose any version ever published 578 | by the Free Software Foundation. 579 | 580 | If the Program specifies that a proxy can decide which future 581 | versions of the GNU Affero General Public License can be used, that proxy's 582 | public statement of acceptance of a version permanently authorizes you 583 | to choose that version for the Program. 584 | 585 | Later license versions may give you additional or different 586 | permissions. However, no additional obligations are imposed on any 587 | author or copyright holder as a result of your choosing to follow a 588 | later version. 589 | 590 | 15. Disclaimer of Warranty. 591 | 592 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 593 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 594 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 595 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 596 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 597 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 598 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 599 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 600 | 601 | 16. Limitation of Liability. 602 | 603 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 604 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 605 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 606 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 607 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 608 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 609 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 610 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 611 | SUCH DAMAGES. 612 | 613 | 17. Interpretation of Sections 15 and 16. 614 | 615 | If the disclaimer of warranty and limitation of liability provided 616 | above cannot be given local legal effect according to their terms, 617 | reviewing courts shall apply local law that most closely approximates 618 | an absolute waiver of all civil liability in connection with the 619 | Program, unless a warranty or assumption of liability accompanies a 620 | copy of the Program in return for a fee. 621 | 622 | END OF TERMS AND CONDITIONS 623 | 624 | How to Apply These Terms to Your New Programs 625 | 626 | If you develop a new program, and you want it to be of the greatest 627 | possible use to the public, the best way to achieve this is to make it 628 | free software which everyone can redistribute and change under these terms. 629 | 630 | To do so, attach the following notices to the program. It is safest 631 | to attach them to the start of each source file to most effectively 632 | state the exclusion of warranty; and each file should have at least 633 | the "copyright" line and a pointer to where the full notice is found. 634 | 635 | 636 | Copyright (C) 637 | 638 | This program is free software: you can redistribute it and/or modify 639 | it under the terms of the GNU Affero General Public License as published by 640 | the Free Software Foundation, either version 3 of the License, or 641 | (at your option) any later version. 642 | 643 | This program is distributed in the hope that it will be useful, 644 | but WITHOUT ANY WARRANTY; without even the implied warranty of 645 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 646 | GNU Affero General Public License for more details. 647 | 648 | You should have received a copy of the GNU Affero General Public License 649 | along with this program. If not, see . 650 | 651 | Also add information on how to contact you by electronic and paper mail. 652 | 653 | If your software can interact with users remotely through a computer 654 | network, you should also make sure that it provides a way for users to 655 | get its source. For example, if your program is a web application, its 656 | interface could display a "Source" link that leads users to an archive 657 | of the code. There are many ways you could offer source, and different 658 | solutions will be better for different programs; see section 13 for the 659 | specific requirements. 660 | 661 | You should also get your employer (if you work as a programmer) or school, 662 | if any, to sign a "copyright disclaimer" for the program, if necessary. 663 | For more information on this, and how to apply and follow the GNU AGPL, see 664 | . --------------------------------------------------------------------------------