freedombone-app-xmpp 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. #!/bin/bash
  2. #
  3. # .---. . .
  4. # | | |
  5. # |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
  6. # | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
  7. # ' ' --' --' -' - -' ' ' -' -' -' ' - --'
  8. #
  9. # Freedom in the Cloud
  10. #
  11. # XMPP functions
  12. #
  13. # License
  14. # =======
  15. #
  16. # Copyright (C) 2014-2016 Bob Mottram <bob@robotics.uk.to>
  17. #
  18. # This program is free software: you can redistribute it and/or modify
  19. # it under the terms of the GNU Affero General Public License as published by
  20. # the Free Software Foundation, either version 3 of the License, or
  21. # (at your option) any later version.
  22. #
  23. # This program is distributed in the hope that it will be useful,
  24. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  26. # GNU Affero General Public License for more details.
  27. #
  28. # You should have received a copy of the GNU Affero General Public License
  29. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  30. # Directory where XMPP settings are stored
  31. XMPP_DIRECTORY="/var/lib/prosody"
  32. XMPP_PASSWORD=
  33. XMPP_CIPHERS='"EDH+CAMELLIA:EDH+aRSA:EECDH+aRSA+AESGCM:EECDH+aRSA+SHA256:EECDH:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!IDEA:!ECDSA:kEDH:CAMELLIA128-SHA:AES128-SHA"'
  34. XMPP_ECC_CURVE='"secp384r1"'
  35. function backup_xmpp {
  36. echo ''
  37. }
  38. function configure_firewall_for_xmpp {
  39. if [ ! -d /etc/prosody ]; then
  40. return
  41. fi
  42. if grep -Fxq "configure_firewall_for_xmpp" $COMPLETION_FILE; then
  43. return
  44. fi
  45. if [[ $INSTALLED_WITHIN_DOCKER == "yes" ]]; then
  46. # docker does its own firewalling
  47. return
  48. fi
  49. if [[ $ONION_ONLY != "no" ]]; then
  50. return
  51. fi
  52. iptables -A INPUT -p tcp --dport 5222:5223 -j ACCEPT
  53. iptables -A INPUT -p tcp --dport 5269 -j ACCEPT
  54. iptables -A INPUT -p tcp --dport 5280:5281 -j ACCEPT
  55. function_check save_firewall_settings
  56. save_firewall_settings
  57. OPEN_PORTS+=('XMPP 5222-5223')
  58. OPEN_PORTS+=('XMPP 5269')
  59. OPEN_PORTS+=('XMPP 5280-5281')
  60. echo 'configure_firewall_for_xmpp' >> $COMPLETION_FILE
  61. }
  62. function update_prosody_modules {
  63. if [ ! -d $INSTALL_DIR/prosody-modules ]; then
  64. return
  65. fi
  66. if [ ! -d /usr/lib/prosody ]; then
  67. return
  68. fi
  69. cd $INSTALL_DIR/prosody-modules
  70. hg pull
  71. hg update
  72. # support onion addresses
  73. if [ -f $INSTALL_DIR/prosody-modules/mod_onions/mod_onions.lua ]; then
  74. cp $INSTALL_DIR/prosody-modules/mod_onions/mod_onions.lua /usr/lib/prosody/modules/mod_onions.lua
  75. fi
  76. # XEP-0313 message archive management
  77. # https://modules.prosody.im/mod_mam.html
  78. # Allows you to download your previous messages onto a new client
  79. # This only applies if you are not using forward secret crypto
  80. # such as OTR or OMEMO (eg. OpenPGP)
  81. if [ -d $INSTALL_DIR/prosody-modules/mod_mam ]; then
  82. cp $INSTALL_DIR/prosody-modules/mod_mam/*.lua /usr/lib/prosody/modules
  83. fi
  84. # XEP-0352 Client State Indication
  85. # Notifies the server if the app is in the background or not
  86. if [ -d $INSTALL_DIR/prosody-modules/mod_csi ]; then
  87. cp $INSTALL_DIR/prosody-modules/mod_csi/*.lua /usr/lib/prosody/modules
  88. fi
  89. # XEP-0280 Message Carbons
  90. # Ensures all messages get delivered to all clients (if you have a mobile and desktop client)
  91. if [ -d $INSTALL_DIR/prosody-modules/mod_carbons ]; then
  92. cp $INSTALL_DIR/prosody-modules/mod_carbons/*.lua /usr/lib/prosody/modules
  93. fi
  94. # XEP-0198 Stream management
  95. # Helps mobile apps recover when a device switches networks.
  96. if [ -d $INSTALL_DIR/prosody-modules/mod_smacks ]; then
  97. cp $INSTALL_DIR/prosody-modules/mod_smacks/*.lua /usr/lib/prosody/modules
  98. fi
  99. if [ -d $INSTALL_DIR/prosody-modules/mod_smacks_offline ]; then
  100. cp $INSTALL_DIR/prosody-modules/mod_smacks_offline/*.lua /usr/lib/prosody/modules
  101. fi
  102. # XEP-0191: blocking
  103. if [ -d $INSTALL_DIR/prosody-modules/mod_blocking ]; then
  104. cp $INSTALL_DIR/prosody-modules/mod_blocking/*.lua /usr/lib/prosody/modules
  105. fi
  106. # XEP-0016 Privacy lists
  107. if [ -d $INSTALL_DIR/prosody-modules/mod_privacy_lists ]; then
  108. cp $INSTALL_DIR/prosody-modules/mod_privacy_lists/*.lua /usr/lib/prosody/modules
  109. fi
  110. }
  111. function remove_xmpp_client {
  112. if ! grep -Fxq "install_xmpp_client" $COMPLETION_FILE; then
  113. return
  114. fi
  115. apt-get -y remove --purge profanity
  116. sed '/install_xmpp_client/d' $COMPLETION_FILE
  117. }
  118. function remove_xmpp {
  119. remove_xmpp_client
  120. if ! grep -Fxq "install_xmpp" $COMPLETION_FILE; then
  121. return
  122. fi
  123. iptables -D INPUT -p tcp --dport 5222:5223 -j ACCEPT
  124. iptables -D INPUT -p tcp --dport 5269 -j ACCEPT
  125. iptables -D INPUT -p tcp --dport 5280:5281 -j ACCEPT
  126. function_check save_firewall_settings
  127. save_firewall_settings
  128. function_check remove_onion_service
  129. remove_onion_service xmpp 5222 5223 5269
  130. apt-get -y remove --purge prosody prosody-modules
  131. if [ -d $INSTALL_DIR/prosody-modules ]; then
  132. rm -rf $INSTALL_DIR/prosody-modules
  133. fi
  134. if [ -d /etc/prosody ]; then
  135. rm -rf /etc/prosody
  136. fi
  137. sed '/install_xmpp/d' $COMPLETION_FILE
  138. sed '/XMPP /d' $COMPLETION_FILE
  139. }
  140. function install_xmpp_main {
  141. if [[ $SYSTEM_TYPE == "$VARIANT_WRITER" || $SYSTEM_TYPE == "$VARIANT_MAILBOX" || $SYSTEM_TYPE == "$VARIANT_CLOUD" || $SYSTEM_TYPE == "$VARIANT_SOCIAL" || $SYSTEM_TYPE == "$VARIANT_MEDIA" || $SYSTEM_TYPE == "$VARIANT_DEVELOPER" || $SYSTEM_TYPE == "$VARIANT_MESH" ]]; then
  142. return
  143. fi
  144. update_prosody_modules
  145. if grep -Fxq "install_xmpp_main" $COMPLETION_FILE; then
  146. return
  147. fi
  148. apt-get -y install lua-sec lua-bitop
  149. apt-get -y install prosody prosody-modules mercurial
  150. if [ ! -d /etc/prosody ]; then
  151. echo $"ERROR: prosody does not appear to have installed. $CHECK_MESSAGE"
  152. exit 52
  153. fi
  154. # obtain the prosody modules
  155. cd $INSTALL_DIR
  156. hg clone https://hg.prosody.im/prosody-modules/ prosody-modules
  157. if [ ! -d $INSTALL_DIR/prosody-modules/mod_onions ]; then
  158. echo $'mod_onions prosody module could not be found'
  159. exit 73254
  160. fi
  161. # install the onions module
  162. update_prosody_modules
  163. if [ ! -f /usr/lib/prosody/modules/mod_onions.lua ]; then
  164. echo $'mod_onions.lua could not be copied to the prosody modules directory'
  165. exit 63952
  166. fi
  167. # create a certificate
  168. if [ ! -f /etc/ssl/certs/xmpp.dhparam ]; then
  169. ${PROJECT_NAME}-addcert -h xmpp --dhkey $DH_KEYLENGTH
  170. check_certificates xmpp
  171. fi
  172. chown prosody:prosody /etc/ssl/private/xmpp.key
  173. chown prosody:prosody /etc/ssl/certs/xmpp.*
  174. cp -a /etc/prosody/conf.avail/example.com.cfg.lua /etc/prosody/conf.avail/xmpp.cfg.lua
  175. sed -i 's|/etc/prosody/certs/example.com.key|/etc/ssl/private/xmpp.key|g' /etc/prosody/conf.avail/xmpp.cfg.lua
  176. sed -i 's|/etc/prosody/certs/example.com.crt|/etc/ssl/certs/xmpp.crt|g' /etc/prosody/conf.avail/xmpp.cfg.lua
  177. if ! grep -q "xmpp.dhparam" /etc/prosody/conf.avail/xmpp.cfg.lua; then
  178. sed -i '/certificate =/a\ dhparam = "/etc/ssl/certs/xmpp.dhparam";' /etc/prosody/conf.avail/xmpp.cfg.lua
  179. fi
  180. if ! grep -q 'options = {"no_sslv2", "no_sslv3" }' /etc/prosody/conf.avail/xmpp.cfg.lua; then
  181. sed -i '/certificate =/a\ options = {"no_sslv2", "no_sslv3" };' /etc/prosody/conf.avail/xmpp.cfg.lua
  182. fi
  183. if ! grep -q 'ciphers =' /etc/prosody/conf.avail/xmpp.cfg.lua; then
  184. sed -i "/certificate =/a\ ciphers = $XMPP_CIPHERS;" /etc/prosody/conf.avail/xmpp.cfg.lua
  185. fi
  186. if ! grep -q 'depth = "1";' /etc/prosody/conf.avail/xmpp.cfg.lua; then
  187. sed -i '/certificate =/a\ depth = "1";' /etc/prosody/conf.avail/xmpp.cfg.lua
  188. fi
  189. if ! grep -q 'curve =' /etc/prosody/conf.avail/xmpp.cfg.lua; then
  190. sed -i "/certificate =/a\ curve = $XMPP_ECC_CURVE;" /etc/prosody/conf.avail/xmpp.cfg.lua
  191. fi
  192. sed -i "s/example.com/$DEFAULT_DOMAIN_NAME/g" /etc/prosody/conf.avail/xmpp.cfg.lua
  193. sed -i 's/enabled = false -- Remove this line to enable this host//g' /etc/prosody/conf.avail/xmpp.cfg.lua
  194. if ! grep -q "modules_enabled" /etc/prosody/conf.avail/xmpp.cfg.lua; then
  195. echo '' >> /etc/prosody/conf.avail/xmpp.cfg.lua
  196. echo 'modules_enabled = {' >> /etc/prosody/conf.avail/xmpp.cfg.lua
  197. echo ' "bosh"; -- Enable mod_bosh' >> /etc/prosody/conf.avail/xmpp.cfg.lua
  198. echo ' "tls"; -- Enable mod_tls' >> /etc/prosody/conf.avail/xmpp.cfg.lua
  199. echo ' "saslauth"; -- Enable mod_saslauth' >> /etc/prosody/conf.avail/xmpp.cfg.lua
  200. echo ' "onions"; -- Enable chat via onion service' >> /etc/prosody/conf.avail/xmpp.cfg.lua
  201. echo ' "mam"; -- Message archive management' >> /etc/prosody/conf.avail/xmpp.cfg.lua
  202. echo ' "csi"; -- Client state indication' >> /etc/prosody/conf.avail/xmpp.cfg.lua
  203. echo ' "carbons"; -- Message carbons' >> /etc/prosody/conf.avail/xmpp.cfg.lua
  204. echo ' "smacks"; -- Stream management' >> /etc/prosody/conf.avail/xmpp.cfg.lua
  205. echo ' "smacks_offline"; -- Stream management' >> /etc/prosody/conf.avail/xmpp.cfg.lua
  206. echo ' "pep"; -- Personal Eventing Protocol (to support OMEMO)' >> /etc/prosody/conf.avail/xmpp.cfg.lua
  207. echo ' "privacy"; -- Privacy lists' >> /etc/prosody/conf.avail/xmpp.cfg.lua
  208. echo ' "privacy_lists"; -- Privacy lists' >> /etc/prosody/conf.avail/xmpp.cfg.lua
  209. echo ' "blocking"; -- Blocking command' >> /etc/prosody/conf.avail/xmpp.cfg.lua
  210. echo ' "roster"; -- Roster versioning' >> /etc/prosody/conf.avail/xmpp.cfg.lua
  211. echo '}' >> /etc/prosody/conf.avail/xmpp.cfg.lua
  212. echo '' >> /etc/prosody/conf.avail/xmpp.cfg.lua
  213. echo 'c2s_require_encryption = true' >> /etc/prosody/conf.avail/xmpp.cfg.lua
  214. echo 's2s_require_encryption = true' >> /etc/prosody/conf.avail/xmpp.cfg.lua
  215. echo 'allow_unencrypted_plain_auth = false' >> /etc/prosody/conf.avail/xmpp.cfg.lua
  216. fi
  217. ln -sf /etc/prosody/conf.avail/xmpp.cfg.lua /etc/prosody/conf.d/xmpp.cfg.lua
  218. sed -i 's|/etc/prosody/certs/localhost.key|/etc/ssl/private/xmpp.key|g' /etc/prosody/prosody.cfg.lua
  219. sed -i 's|/etc/prosody/certs/localhost.crt|/etc/ssl/certs/xmpp.crt|g' /etc/prosody/prosody.cfg.lua
  220. if ! grep -q "xmpp.dhparam" /etc/prosody/prosody.cfg.lua; then
  221. sed -i '/certificate =/a\ dhparam = "/etc/ssl/certs/xmpp.dhparam";' /etc/prosody/prosody.cfg.lua
  222. fi
  223. if ! grep -q 'options = {"no_sslv2", "no_sslv3" }' /etc/prosody/prosody.cfg.lua; then
  224. sed -i '/certificate =/a\ options = {"no_sslv2", "no_sslv3" };' /etc/prosody/prosody.cfg.lua
  225. fi
  226. if ! grep -q 'ciphers =' /etc/prosody/prosody.cfg.lua; then
  227. sed -i "/certificate =/a\ ciphers = $XMPP_CIPHERS;" /etc/prosody/prosody.cfg.lua
  228. fi
  229. if ! grep -q 'depth = "1";' /etc/prosody/prosody.cfg.lua; then
  230. sed -i '/certificate =/a\ depth = "1";' /etc/prosody/prosody.cfg.lua
  231. fi
  232. if ! grep -q 'curve =' /etc/prosody/prosody.cfg.lua; then
  233. sed -i "/certificate =/a\ curve = $XMPP_ECC_CURVE;" /etc/prosody/prosody.cfg.lua
  234. fi
  235. sed -i 's/c2s_require_encryption = false/c2s_require_encryption = true/g' /etc/prosody/prosody.cfg.lua
  236. if ! grep -q "s2s_require_encryption" /etc/prosody/prosody.cfg.lua; then
  237. sed -i '/c2s_require_encryption/a\s2s_require_encryption = true' /etc/prosody/prosody.cfg.lua
  238. fi
  239. if ! grep -q "allow_unencrypted_plain_auth" /etc/prosody/prosody.cfg.lua; then
  240. echo 'allow_unencrypted_plain_auth = false' >> /etc/prosody/conf.avail/xmpp.cfg.lua
  241. fi
  242. sed -i 's/--"bosh";/"bosh";/g' /etc/prosody/prosody.cfg.lua
  243. sed -i 's/authentication = "internal_plain"/authentication = "internal_hashed"/g' /etc/prosody/prosody.cfg.lua
  244. sed -i 's/enabled = false -- Remove this line to enable this host//g' /etc/prosody/prosody.cfg.lua
  245. sed -i 's|key = "/etc/prosody/certs/example.com.key"|key = "/etc/ssl/private/xmpp.key"|g' /etc/prosody/prosody.cfg.lua
  246. sed -i 's|certificate = "/etc/prosody/certs/example.com.crt"|certificate = "/etc/ssl/certs/xmpp.crt"|g' /etc/prosody/prosody.cfg.lua
  247. sed -i "s/example.com/$DEFAULT_DOMAIN_NAME/g" /etc/prosody/prosody.cfg.lua
  248. systemctl restart prosody
  249. touch /home/$MY_USERNAME/README
  250. if [ ! -d /var/lib/tor ]; then
  251. echo $'No Tor installation found. XMPP onion site cannot be configured.'
  252. exit 877367
  253. fi
  254. if ! grep -q "hidden_service_xmpp" /etc/tor/torrc; then
  255. echo 'HiddenServiceDir /var/lib/tor/hidden_service_xmpp/' >> /etc/tor/torrc
  256. echo "HiddenServicePort 5222 127.0.0.1:5222" >> /etc/tor/torrc
  257. echo "HiddenServicePort 5269 127.0.0.1:5269" >> /etc/tor/torrc
  258. echo $'Added onion site for XMPP chat'
  259. fi
  260. systemctl restart tor
  261. wait_for_onion_service 'xmpp'
  262. if [ ! -f /var/lib/tor/hidden_service_xmpp/hostname ]; then
  263. echo $'XMPP onion site hostname not found'
  264. exit 65349
  265. fi
  266. XMPP_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_xmpp/hostname)
  267. if ! grep -q "${XMPP_ONION_HOSTNAME}" /etc/prosody/conf.avail/xmpp.cfg.lua; then
  268. echo '' >> /etc/prosody/conf.avail/xmpp.cfg.lua
  269. echo "VirtualHost \"${XMPP_ONION_HOSTNAME}\"" >> /etc/prosody/conf.avail/xmpp.cfg.lua
  270. echo ' modules_enabled = { "onions" };' >> /etc/prosody/conf.avail/xmpp.cfg.lua
  271. fi
  272. if ! grep -q "XMPP onion domain" $COMPLETION_FILE; then
  273. echo "XMPP onion domain:${XMPP_ONION_HOSTNAME}" >> $COMPLETION_FILE
  274. else
  275. sed -i "s|XMPP onion domain.*|XMPP onion domain:${XMPP_ONION_HOSTNAME}|g" $COMPLETION_FILE
  276. fi
  277. if ! grep -q "Your XMPP password is" /home/$MY_USERNAME/README; then
  278. if [ ${#XMPP_PASSWORD} -lt 8 ]; then
  279. if [ -f $IMAGE_PASSWORD_FILE ]; then
  280. XMPP_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
  281. else
  282. XMPP_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
  283. fi
  284. fi
  285. prosodyctl register $MY_USERNAME $DEFAULT_DOMAIN_NAME $XMPP_PASSWORD
  286. echo '' >> /home/$MY_USERNAME/README
  287. echo '' >> /home/$MY_USERNAME/README
  288. echo $'XMPP' >> /home/$MY_USERNAME/README
  289. echo '====' >> /home/$MY_USERNAME/README
  290. echo $"XMPP onion domain: ${XMPP_ONION_HOSTNAME}" >> /home/$MY_USERNAME/README
  291. echo $"Your XMPP password is: $XMPP_PASSWORD" >> /home/$MY_USERNAME/README
  292. echo $'You can change it with: ' >> /home/$MY_USERNAME/README
  293. echo '' >> /home/$MY_USERNAME/README
  294. echo " prosodyctl passwd $MY_EMAIL_ADDRESS" >> /home/$MY_USERNAME/README
  295. chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
  296. chmod 600 /home/$MY_USERNAME/README
  297. fi
  298. function_check configure_firewall_for_xmpp
  299. configure_firewall_for_xmpp
  300. echo 'install_xmpp_main' >> $COMPLETION_FILE
  301. }
  302. function install_xmpp_client {
  303. if [[ $SYSTEM_TYPE == "$VARIANT_WRITER" || $SYSTEM_TYPE == "$VARIANT_MAILBOX" || $SYSTEM_TYPE == "$VARIANT_CLOUD" || $SYSTEM_TYPE == "$VARIANT_SOCIAL" || $SYSTEM_TYPE == "$VARIANT_MEDIA" || $SYSTEM_TYPE == "$VARIANT_DEVELOPER" || $SYSTEM_TYPE == "$VARIANT_MESH" ]]; then
  304. return
  305. fi
  306. if grep -Fxq "install_xmpp_client" $COMPLETION_FILE; then
  307. return
  308. fi
  309. apt-get -y install profanity
  310. XMPP_CLIENT_DIR=/home/$MY_USERNAME/.local/share/profanity
  311. XMPP_CLIENT_ACCOUNTS=$XMPP_CLIENT_DIR/accounts
  312. if [ ! -d $XMPP_CLIENT_DIR ]; then
  313. mkdir -p $XMPP_CLIENT_DIR
  314. fi
  315. if [[ $ONION_ONLY == 'no' ]]; then
  316. echo "[${MY_USERNAME}@${DEFAULT_DOMAIN_NAME}]" > $XMPP_CLIENT_ACCOUNTS
  317. echo 'enabled=true' >> $XMPP_CLIENT_ACCOUNTS
  318. echo "jid=${MY_USERNAME}@${DEFAULT_DOMAIN_NAME}" >> $XMPP_CLIENT_ACCOUNTS
  319. echo 'resource=profanity' >> $XMPP_CLIENT_ACCOUNTS
  320. echo "muc.service=conference.${DEFAULT_DOMAIN_NAME}" >> $XMPP_CLIENT_ACCOUNTS
  321. echo "muc.nick=${MY_USERNAME}" >> $XMPP_CLIENT_ACCOUNTS
  322. echo 'presence.last=online' >> $XMPP_CLIENT_ACCOUNTS
  323. echo 'presence.login=online' >> $XMPP_CLIENT_ACCOUNTS
  324. echo 'priority.online=0' >> $XMPP_CLIENT_ACCOUNTS
  325. echo 'priority.chat=0' >> $XMPP_CLIENT_ACCOUNTS
  326. echo 'priority.away=0' >> $XMPP_CLIENT_ACCOUNTS
  327. echo 'priority.xa=0' >> $XMPP_CLIENT_ACCOUNTS
  328. echo 'priority.dnd=0' >> $XMPP_CLIENT_ACCOUNTS
  329. if [ ${#XMPP_PASSWORD} -gt 2 ]; then
  330. echo "password=$XMPP_PASSWORD" >> $XMPP_CLIENT_ACCOUNTS
  331. fi
  332. fi
  333. if [ -f /var/lib/tor/hidden_service_xmpp/hostname ]; then
  334. XMPP_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_xmpp/hostname)
  335. echo "[${MY_USERNAME}@${XMPP_ONION_HOSTNAME}]" >> $XMPP_CLIENT_ACCOUNTS
  336. if [[ $ONION_ONLY == 'no' ]]; then
  337. echo 'enabled=false' >> $XMPP_CLIENT_ACCOUNTS
  338. else
  339. echo 'enabled=true' >> $XMPP_CLIENT_ACCOUNTS
  340. fi
  341. echo "jid=${MY_USERNAME}@${XMPP_ONION_HOSTNAME}" >> $XMPP_CLIENT_ACCOUNTS
  342. echo 'resource=profanity' >> $XMPP_CLIENT_ACCOUNTS
  343. echo "muc.service=conference.${XMPP_ONION_HOSTNAME}" >> $XMPP_CLIENT_ACCOUNTS
  344. echo "muc.nick=${MY_USERNAME}" >> $XMPP_CLIENT_ACCOUNTS
  345. echo 'presence.last=online' >> $XMPP_CLIENT_ACCOUNTS
  346. echo 'presence.login=online' >> $XMPP_CLIENT_ACCOUNTS
  347. echo 'priority.online=0' >> $XMPP_CLIENT_ACCOUNTS
  348. echo 'priority.chat=0' >> $XMPP_CLIENT_ACCOUNTS
  349. echo 'priority.away=0' >> $XMPP_CLIENT_ACCOUNTS
  350. echo 'priority.xa=0' >> $XMPP_CLIENT_ACCOUNTS
  351. echo 'priority.dnd=0' >> $XMPP_CLIENT_ACCOUNTS
  352. if [ ${#XMPP_PASSWORD} -gt 2 ]; then
  353. echo "password=$XMPP_PASSWORD" >> $XMPP_CLIENT_ACCOUNTS
  354. fi
  355. fi
  356. if [ ! -d /home/$MY_USERNAME/.config/profanity ]; then
  357. mkdir /home/$MY_USERNAME/.config/profanity
  358. fi
  359. echo '[connection]' > /home/$MY_USERNAME/.config/profanity/profrc
  360. echo "account=${MY_USERNAME}@${DEFAULT_DOMAIN_NAME}" >> /home/$MY_USERNAME/.config/profanity/profrc
  361. chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.local
  362. chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.config
  363. echo 'install_xmpp_client' >> $COMPLETION_FILE
  364. }
  365. function install_xmpp {
  366. if grep -Fxq "install_xmpp" $COMPLETION_FILE; then
  367. return
  368. fi
  369. install_xmpp_main
  370. install_xmpp_client
  371. echo 'install_xmpp' >> $COMPLETION_FILE
  372. }
  373. # NOTE: deliberately no exit 0