freedombone-app-postactiv 37KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989
  1. #!/bin/bash
  2. # _____ _ _
  3. # | __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
  4. # | __| _| -_| -_| . | . | | . | . | | -_|
  5. # |__| |_| |___|___|___|___|_|_|_|___|___|_|_|___|
  6. #
  7. # Freedom in the Cloud
  8. #
  9. # postactiv application
  10. #
  11. # License
  12. # =======
  13. #
  14. # Copyright (C) 2016-2018 Bob Mottram <bob@freedombone.net>
  15. #
  16. # This program is free software: you can redistribute it and/or modify
  17. # it under the terms of the GNU Affero General Public License as published by
  18. # the Free Software Foundation, either version 3 of the License, or
  19. # (at your option) any later version.
  20. #
  21. # This program is distributed in the hope that it will be useful,
  22. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. # GNU Affero General Public License for more details.
  25. #
  26. # You should have received a copy of the GNU Affero General Public License
  27. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  28. VARIANTS='full full-vim media'
  29. IN_DEFAULT_INSTALL=0
  30. SHOW_ON_ABOUT=1
  31. NOT_ON_ONION=1
  32. POSTACTIV_DOMAIN_NAME=
  33. POSTACTIV_CODE=
  34. POSTACTIV_ONION_PORT=8100
  35. POSTACTIV_REPO="http://gitea.postactiv.com/postActiv/postActiv.git"
  36. POSTACTIV_COMMIT='3c88992eeb'
  37. POSTACTIV_ADMIN_PASSWORD=
  38. POSTACTIV_BACKGROUND_IMAGE_URL=
  39. POSTACTIV_TITLE='PostActiv'
  40. # Number of months after which posts expire
  41. POSTACTIV_EXPIRE_MONTHS=3
  42. POSTACTIV_SHORT_DESCRIPTION=$'Federated microblogging'
  43. POSTACTIV_DESCRIPTION=$'Federated microblogging'
  44. POSTACTIV_MOBILE_APP_URL='https://f-droid.org/packages/org.mariotaku.twidere/'
  45. postactiv_variables=(ONION_ONLY
  46. POSTACTIV_DOMAIN_NAME
  47. POSTACTIV_CODE
  48. DDNS_PROVIDER
  49. MY_USERNAME
  50. POSTACTIV_BACKGROUND_IMAGE_URL
  51. POSTACTIV_EXPIRE_MONTHS
  52. POSTACTIV_TITLE)
  53. function logging_on_postactiv {
  54. echo -n ''
  55. }
  56. function logging_off_postactiv {
  57. echo -n ''
  58. }
  59. function postactiv_customise_logo {
  60. domain_name=$1
  61. if [ -f "/var/www/${domain_name}/htdocs/static/logo.png" ]; then
  62. if [ -f "$HOME/${PROJECT_NAME}/img/postactiv.png" ]; then
  63. cp "$HOME/${PROJECT_NAME}/img/postactiv.png" "/var/www/${domain_name}/htdocs/static/logo.png"
  64. else
  65. if [ -f "/home/$MY_USERNAME/${PROJECT_NAME}/img/postactiv.png" ]; then
  66. cp "/home/$MY_USERNAME/${PROJECT_NAME}/img/postactiv.png" "/var/www/${domain_name}/htdocs/static/logo.png"
  67. fi
  68. fi
  69. fi
  70. }
  71. function remove_user_postactiv {
  72. remove_username="$1"
  73. "${PROJECT_NAME}-pass" -u "$remove_username" --rmapp postactiv
  74. function_check get_completion_param
  75. POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
  76. if [ -d "/var/www/$POSTACTIV_DOMAIN_NAME" ]; then
  77. cd "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs" || exit 3658254254
  78. php scripts/deleteprofile.php -n "$remove_username" -y
  79. fi
  80. }
  81. function add_user_postactiv {
  82. new_username="$1"
  83. new_user_password="$2"
  84. "${PROJECT_NAME}-pass" -u "$new_username" -a postactiv -p "$new_user_password"
  85. POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
  86. if [ -d "/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs" ]; then
  87. cd "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs" || exit 346846834
  88. php scripts/registeruser.php -n "$new_username" -w "$new_user_password" -e "$new_username@$HOSTNAME"
  89. "${PROJECT_NAME}-addemail" -u "$new_username" -e "noreply@$POSTACTIV_DOMAIN_NAME" -g postactiv --public no
  90. echo '0'
  91. else
  92. echo '1'
  93. fi
  94. }
  95. function install_interactive_postactiv {
  96. if [ ! "$ONION_ONLY" ]; then
  97. ONION_ONLY='no'
  98. fi
  99. if [[ $ONION_ONLY != "no" ]]; then
  100. POSTACTIV_DOMAIN_NAME='postactiv.local'
  101. else
  102. POSTACTIV_DETAILS_COMPLETE=
  103. while [ ! $POSTACTIV_DETAILS_COMPLETE ]
  104. do
  105. data=$(mktemp 2>/dev/null)
  106. if [[ "$DDNS_PROVIDER" == *"freedns"* ]]; then
  107. dialog --backtitle $"Freedombone Configuration" \
  108. --title $"PostActiv Configuration" \
  109. --form $"\\nPlease enter your PostActiv details. The background image URL can be left blank.\\n\\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 16 65 4 \
  110. $"Domain:" 1 1 "$(grep 'POSTACTIV_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 25 33 40 \
  111. $"Title:" 2 1 "$(grep "$POSTACTIV_TITLE" temp.cfg | awk -F '=' '{print $2}')" 2 25 255 255 \
  112. $"Background image URL:" 3 1 "$(grep "$POSTACTIV_BACKGROUND_IMAGE_URL" temp.cfg | awk -F '=' '{print $2}')" 3 25 255 255 \
  113. $"Code:" 4 1 "$(grep 'POSTACTIV_CODE' temp.cfg | awk -F '=' '{print $2}')" 4 25 33 255 \
  114. 2> "$data"
  115. else
  116. dialog --backtitle $"Freedombone Configuration" \
  117. --title $"PostActiv Configuration" \
  118. --form $"\\nPlease enter your PostActiv details. The background image URL can be left blank.\\n\\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 16 65 4 \
  119. $"Domain:" 1 1 "$(grep 'POSTACTIV_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 25 33 40 \
  120. $"Title:" 2 1 "$(grep "$POSTACTIV_TITLE" temp.cfg | awk -F '=' '{print $2}')" 2 25 255 255 \
  121. $"Background image URL:" 3 1 "$(grep "$POSTACTIV_BACKGROUND_IMAGE_URL" temp.cfg | awk -F '=' '{print $2}')" 3 25 255 255 \
  122. 2> "$data"
  123. fi
  124. sel=$?
  125. case $sel in
  126. 1) rm -f "$data"
  127. exit 1;;
  128. 255) rm -f "$data"
  129. exit 1;;
  130. esac
  131. POSTACTIV_DOMAIN_NAME=$(sed -n 1p < "$data")
  132. title=$(sed -n 2p < "$data")
  133. if [ ${#title} -gt 1 ]; then
  134. POSTACTIV_TITLE=$title
  135. fi
  136. img_url=$(sed -n 3p < "$data")
  137. if [ ${#img_url} -gt 1 ]; then
  138. POSTACTIV_BACKGROUND_IMAGE_URL=$img_url
  139. fi
  140. if [ "$POSTACTIV_DOMAIN_NAME" ]; then
  141. if [[ "$POSTACTIV_DOMAIN_NAME" == "$HUBZILLA_DOMAIN_NAME" ]]; then
  142. POSTACTIV_DOMAIN_NAME=""
  143. fi
  144. TEST_DOMAIN_NAME=$POSTACTIV_DOMAIN_NAME
  145. validate_domain_name
  146. if [[ "$TEST_DOMAIN_NAME" != "$POSTACTIV_DOMAIN_NAME" ]]; then
  147. POSTACTIV_DOMAIN_NAME=
  148. dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
  149. else
  150. if [[ "$DDNS_PROVIDER" == *"freedns"* ]]; then
  151. POSTACTIV_CODE=$(sed -n 4p < "$data")
  152. validate_freedns_code "$POSTACTIV_CODE"
  153. if [ ! "$VALID_CODE" ]; then
  154. POSTACTIV_DOMAIN_NAME=
  155. fi
  156. fi
  157. fi
  158. fi
  159. if [ $POSTACTIV_DOMAIN_NAME ]; then
  160. POSTACTIV_DETAILS_COMPLETE="yes"
  161. fi
  162. rm -f "$data"
  163. done
  164. # remove any invalid characters
  165. if [ ${#POSTACTIV_TITLE} -gt 0 ]; then
  166. new_title=${POSTACTIV_TITLE//\'/}
  167. POSTACTIV_TITLE="$new_title"
  168. fi
  169. # save the results in the config file
  170. write_config_param "POSTACTIV_CODE" "$POSTACTIV_CODE"
  171. write_config_param "POSTACTIV_TITLE" "$POSTACTIV_TITLE"
  172. write_config_param "POSTACTIV_BACKGROUND_IMAGE_URL" "$POSTACTIV_BACKGROUND_IMAGE_URL"
  173. fi
  174. write_config_param "POSTACTIV_DOMAIN_NAME" "$POSTACTIV_DOMAIN_NAME"
  175. APP_INSTALLED=1
  176. }
  177. function change_password_postactiv {
  178. curr_username="$1"
  179. new_user_password="$2"
  180. read_config_param 'POSTACTIV_DOMAIN_NAME'
  181. cd "/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/scripts" || exit 246824682
  182. php setpassword.php "$curr_username" "$new_user_password"
  183. "${PROJECT_NAME}-pass" -u "$curr_username" -a postactiv -p "$new_user_password"
  184. }
  185. function postactiv_create_database {
  186. if [ -f "$IMAGE_PASSWORD_FILE" ]; then
  187. POSTACTIV_ADMIN_PASSWORD="$(printf "%s" "$(cat "$IMAGE_PASSWORD_FILE")")"
  188. else
  189. if [ ! "$POSTACTIV_ADMIN_PASSWORD" ]; then
  190. POSTACTIV_ADMIN_PASSWORD="$(create_password "${MINIMUM_PASSWORD_LENGTH}")"
  191. fi
  192. fi
  193. if [ ! "$POSTACTIV_ADMIN_PASSWORD" ]; then
  194. return
  195. fi
  196. function_check create_database
  197. create_database postactiv "$POSTACTIV_ADMIN_PASSWORD" "$MY_USERNAME"
  198. }
  199. function postactiv_running_script {
  200. gnusocial_hourly_script postactiv $POSTACTIV_DOMAIN_NAME
  201. # This was a hack to fix a bug in master, but may no longer be needed
  202. #echo "if ! grep -q \"//define('POSTACTIV',true);\" scripts/commandline.inc; then" >> /etc/cron.hourly/postactiv-daemons
  203. #echo " sed -i \"s|define('POSTACTIV',true);|//define('POSTACTIV',true);|g\" scripts/commandline.inc" >> /etc/cron.hourly/postactiv-daemons
  204. #echo 'fi' >> /etc/cron.hourly/postactiv-daemons
  205. }
  206. function reconfigure_postactiv {
  207. echo -n ''
  208. }
  209. function postactiv_set_background_image {
  210. POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
  211. data=$(mktemp 2>/dev/null)
  212. dialog --title $"PostActiv" \
  213. --backtitle $"Freedombone Control Panel" \
  214. --inputbox $'Set a background image URL' 10 60 2>"$data"
  215. sel=$?
  216. case $sel in
  217. 0)
  218. temp_background=$(<"$data")
  219. if [ ${#temp_background} -gt 0 ]; then
  220. POSTACTIV_BACKGROUND_IMAGE_URL="$temp_background"
  221. write_config_param "POSTACTIV_BACKGROUND_IMAGE_URL" "$POSTACTIV_BACKGROUND_IMAGE_URL"
  222. if [[ $(pleroma_set_background_image_from_url "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs" "$POSTACTIV_DOMAIN_NAME" "$POSTACTIV_BACKGROUND_IMAGE_URL" "$POSTACTIV_TITLE" | tail -n 1) == "0" ]]; then
  223. dialog --title $"Set PostActiv background" \
  224. --msgbox $"The background image has been set" 6 60
  225. fi
  226. fi
  227. ;;
  228. esac
  229. rm -f "$data"
  230. }
  231. function postactiv_set_title {
  232. data=$(mktemp 2>/dev/null)
  233. dialog --title $"PostActiv" \
  234. --backtitle $"Freedombone Control Panel" \
  235. --inputbox $'Set a title' 10 60 2>"$data"
  236. sel=$?
  237. case $sel in
  238. 0)
  239. new_title=$(<"$data")
  240. if [ ${#new_title} -gt 0 ]; then
  241. POSTACTIV_TITLE="$new_title"
  242. POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
  243. write_config_param "POSTACTIV_TITLE" "$POSTACTIV_TITLE"
  244. cd "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs/static" || exit 782452452
  245. sed -i "s|\"name\":.*|\"name\": \"${POSTACTIV_TITLE}\",|g" config.json
  246. dialog --title $"Set PostActiv title" \
  247. --msgbox $"The title has been set" 6 60
  248. fi
  249. ;;
  250. esac
  251. rm -f "$data"
  252. }
  253. function postactiv_set_expire_months {
  254. POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
  255. read_config_param "POSTACTIV_EXPIRE_MONTHS"
  256. data=$(mktemp 2>/dev/null)
  257. dialog --title $"PostActiv" \
  258. --backtitle $"Freedombone Control Panel" \
  259. --inputbox $'Set an expiry period for posts in months. Anything older will be deleted. Lower values help to keep the database size small and as fast as possible.' 12 60 "$POSTACTIV_EXPIRE_MONTHS" 2>"$data"
  260. sel=$?
  261. case $sel in
  262. 0)
  263. new_expiry_months=$(<"$data")
  264. if [ ${#new_expiry_months} -gt 0 ]; then
  265. # should contain no spaces
  266. if [[ "$new_expiry_months" == *" "* ]]; then
  267. return
  268. fi
  269. # should be a number
  270. re='^[0-9]+$'
  271. if ! [[ $new_expiry_months =~ $re ]] ; then
  272. return
  273. fi
  274. # set the new value
  275. POSTACTIV_EXPIRE_MONTHS=$new_expiry_months
  276. write_config_param "POSTACTIV_EXPIRE_MONTHS" "$POSTACTIV_EXPIRE_MONTHS"
  277. expire_gnusocial_posts "$POSTACTIV_DOMAIN_NAME" "postactiv" "$POSTACTIV_EXPIRE_MONTHS"
  278. dialog --title $"Set PostActiv post expiry period" \
  279. --msgbox $"Expiry period set to $POSTACTIV_EXPIRE_MONTHS months" 6 60
  280. fi
  281. ;;
  282. esac
  283. rm -f "$data"
  284. }
  285. function configure_interactive_postactiv {
  286. read_config_param "POSTACTIV_EXPIRE_MONTHS"
  287. while true
  288. do
  289. W=(1 $"Set a background image"
  290. 2 $"Set the title"
  291. 3 $"Set post expiry period (currently $POSTACTIV_EXPIRE_MONTHS months)"
  292. 4 $"Select Qvitter user interface"
  293. 5 $"Select Pleroma user interface"
  294. 6 $"Select Classic user interface")
  295. # shellcheck disable=SC2068
  296. selection=$(dialog --backtitle $"Freedombone Administrator Control Panel" --title $"PostActiv" --menu $"Choose an operation, or ESC to exit:" 15 60 6 "${W[@]}" 3>&2 2>&1 1>&3)
  297. if [ ! "$selection" ]; then
  298. break
  299. fi
  300. case $selection in
  301. 1) postactiv_set_background_image;;
  302. 2) postactiv_set_title;;
  303. 3) postactiv_set_expire_months;;
  304. 4) gnusocial_use_qvitter postactiv;;
  305. 5) gnusocial_use_pleroma postactiv;;
  306. 6) gnusocial_use_classic postactiv;;
  307. esac
  308. done
  309. }
  310. function upgrade_postactiv {
  311. CURR_POSTACTIV_COMMIT=$(get_completion_param "postactiv commit")
  312. if [[ "$CURR_POSTACTIV_COMMIT" == "$POSTACTIV_COMMIT" ]]; then
  313. return
  314. fi
  315. if grep -q "postactiv domain" "$COMPLETION_FILE"; then
  316. POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
  317. fi
  318. # update to the next commit
  319. function_check set_repo_commit
  320. set_repo_commit "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs" "postactiv commit" "$POSTACTIV_COMMIT" $POSTACTIV_REPO
  321. # Ensure that installation script is removed
  322. if [ -f "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs/install.php" ]; then
  323. rm "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs/install.php"
  324. fi
  325. if [ -f "/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/index_qvitter.php" ]; then
  326. if [ -f "/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/index.php" ]; then
  327. # shellcheck disable=SC2086
  328. mv /var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/index.php /var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/index_qvitter.php
  329. fi
  330. fi
  331. function_check postactiv_running_script
  332. postactiv_running_script
  333. gnusocial_block_user_script
  334. gnusocial_block_domain_script postactiv "$POSTACTIV_DOMAIN_NAME"
  335. upgrade_pleroma_frontend "$POSTACTIV_DOMAIN_NAME" "postactiv" "$POSTACTIV_BACKGROUND_IMAGE_URL" "$POSTACTIV_TITLE"
  336. postactiv_customise_logo "$POSTACTIV_DOMAIN_NAME"
  337. install_gnusocial_default_background "postactiv" "$POSTACTIV_DOMAIN_NAME"
  338. chown -R www-data:www-data "/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs"
  339. systemctl restart mariadb
  340. }
  341. function backup_local_postactiv {
  342. POSTACTIV_DOMAIN_NAME='postactiv'
  343. if grep -q "postactiv domain" "$COMPLETION_FILE"; then
  344. POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
  345. fi
  346. # don't backup more data than we need to
  347. /etc/cron.daily/postactiv-expire
  348. source_directory=/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/backup
  349. if [ ! -d "$source_directory" ]; then
  350. mkdir "$source_directory"
  351. fi
  352. cp -p "/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/config.php" "$source_directory"
  353. if [ -d "/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/static" ]; then
  354. cp -rp "/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/static" "$source_directory"
  355. fi
  356. function_check suspend_site
  357. suspend_site "${POSTACTIV_DOMAIN_NAME}"
  358. function_check backup_directory_to_usb
  359. dest_directory=postactivconfig
  360. backup_directory_to_usb "$source_directory" "$dest_directory"
  361. source_directory=/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/file
  362. dest_directory=postactivfile
  363. backup_directory_to_usb "$source_directory" "$dest_directory"
  364. function_check backup_database_to_usb
  365. backup_database_to_usb postactiv
  366. function_check restart_site
  367. restart_site
  368. }
  369. function restore_local_postactiv {
  370. if ! grep -q "postactiv domain" "$COMPLETION_FILE"; then
  371. return
  372. fi
  373. POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
  374. if [ "$POSTACTIV_DOMAIN_NAME" ]; then
  375. echo $"Restoring postactiv"
  376. temp_restore_dir=/root/temppostactiv
  377. postactiv_dir=/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs
  378. # stop the daemons
  379. cd "$postactiv_dir" || exit 468246242
  380. scripts/stopdaemons.sh
  381. function_check postactiv_create_database
  382. postactiv_create_database
  383. restore_database postactiv
  384. if [ -d $temp_restore_dir ]; then
  385. rm -rf $temp_restore_dir
  386. fi
  387. function_check restore_directory_from_usb
  388. restore_directory_from_usb $temp_restore_dir postactivconfig
  389. if [ -d $temp_restore_dir ]; then
  390. if [ -d "$temp_restore_dir$postactiv_dir" ]; then
  391. cp "$temp_restore_dir$postactiv_dir/backup/config.php" "$postactiv_dir/"
  392. cp -rp "$temp_restore_dir$postactiv_dir/static" "$postactiv_dir/"
  393. else
  394. cp "$temp_restore_dir/backup/config.php" "$postactiv_dir/"
  395. if [ ! -d "$postactiv_dir/static" ]; then
  396. mkdir "$postactiv_dir/static"
  397. fi
  398. cp -rp "$temp_restore_dir/static/"* "$postactiv_dir/static/"
  399. fi
  400. chown www-data:www-data "$postactiv_dir/config.php"
  401. chown -R www-data:www-data "$postactiv_dir/static"
  402. rm -rf $temp_restore_dir
  403. fi
  404. restore_directory_from_usb $temp_restore_dir postactivfile
  405. if [ -d $temp_restore_dir ]; then
  406. if [ -d "$temp_restore_dir$postactiv_dir/file" ]; then
  407. cp -rp "$temp_restore_dir$postactiv_dir/file" "$postactiv_dir/"
  408. else
  409. if [ ! -d "$postactiv_dir/file" ]; then
  410. mkdir "$postactiv_dir/file"
  411. fi
  412. cp -rp "$temp_restore_dir/"* "$postactiv_dir/file/"
  413. fi
  414. chown -R www-data:www-data "$postactiv_dir/file"
  415. rm -rf $temp_restore_dir
  416. fi
  417. gnusocial_update_after_restore postactiv "${POSTACTIV_DOMAIN_NAME}"
  418. echo $"Restore of postactiv complete"
  419. fi
  420. }
  421. function backup_remote_postactiv {
  422. POSTACTIV_DOMAIN_NAME='postactiv'
  423. if grep -q "postactiv domain" "$COMPLETION_FILE"; then
  424. POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
  425. fi
  426. # don't backup more data than we need to
  427. /etc/cron.daily/postactiv-expire
  428. source_directory=/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/backup
  429. if [ ! -d "$source_directory" ]; then
  430. mkdir "$source_directory"
  431. fi
  432. cp -p "/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/config.php" "$source_directory"
  433. if [ -d "/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/static" ]; then
  434. cp -rp "/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/static" "$source_directory"
  435. fi
  436. function_check suspend_site
  437. suspend_site "${POSTACTIV_DOMAIN_NAME}"
  438. function_check backup_directory_to_friend
  439. dest_directory=postactivconfig
  440. backup_directory_to_friend "$source_directory" "$dest_directory"
  441. source_directory=/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/file
  442. dest_directory=postactivfile
  443. backup_directory_to_friend "$source_directory" "$dest_directory"
  444. function_check backup_database_to_friend
  445. backup_database_to_friend postactiv
  446. function_check restart_site
  447. restart_site
  448. }
  449. function restore_remote_postactiv {
  450. if ! grep -q "postactiv domain" "$COMPLETION_FILE"; then
  451. return
  452. fi
  453. POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
  454. if [ "$POSTACTIV_DOMAIN_NAME" ]; then
  455. echo $"Restoring postactiv"
  456. temp_restore_dir=/root/temppostactiv
  457. postactiv_dir=/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs
  458. # stop the daemons
  459. cd "$postactiv_dir" || exit 24682464
  460. scripts/stopdaemons.sh
  461. function_check postactiv_create_database
  462. postactiv_create_database
  463. function_check restore_database_from_friend
  464. restore_database_from_friend postactiv
  465. if [ -d $temp_restore_dir ]; then
  466. rm -rf $temp_restore_dir
  467. fi
  468. function_check restore_directory_from_friend
  469. restore_directory_from_friend $temp_restore_dir postactivconfig
  470. if [ -d $temp_restore_dir ]; then
  471. if [ -d "$temp_restore_dir$postactiv_dir" ]; then
  472. cp "$temp_restore_dir$postactiv_dir/backup/config.php" "$postactiv_dir/"
  473. cp -rp "$temp_restore_dir$postactiv_dir/static" "$postactiv_dir/"
  474. else
  475. cp "$temp_restore_dir/config.php" "$postactiv_dir/"
  476. if [ ! -d "$postactiv_dir/static" ]; then
  477. mkdir "$postactiv_dir/static"
  478. fi
  479. cp -rp "$temp_restore_dir/static/"* "$postactiv_dir/static/"
  480. fi
  481. chown www-data:www-data "$postactiv_dir/config.php"
  482. chown -R www-data:www-data "$postactiv_dir/static"
  483. rm -rf $temp_restore_dir
  484. fi
  485. restore_directory_from_friend $temp_restore_dir postactivfile
  486. if [ -d $temp_restore_dir ]; then
  487. if [ -d "$temp_restore_dir$postactiv_dir/file" ]; then
  488. cp -rp "$temp_restore_dir$postactiv_dir/file" "$postactiv_dir/"
  489. else
  490. if [ ! -d "$postactiv_dir/file" ]; then
  491. mkdir "$postactiv_dir/file"
  492. fi
  493. cp -rp "$temp_restore_dir/"* "$postactiv_dir/file/"
  494. fi
  495. chown -R www-data:www-data "$postactiv_dir/file"
  496. rm -rf $temp_restore_dir
  497. fi
  498. gnusocial_update_after_restore postactiv "${POSTACTIV_DOMAIN_NAME}"
  499. echo $"Restore of postactiv complete"
  500. fi
  501. }
  502. function remove_postactiv {
  503. if [ ${#POSTACTIV_DOMAIN_NAME} -eq 0 ]; then
  504. return
  505. fi
  506. function_check remove_nodejs
  507. remove_nodejs pleroma-postactiv
  508. read_config_param "POSTACTIV_DOMAIN_NAME"
  509. read_config_param "MY_USERNAME"
  510. echo "Removing $POSTACTIV_DOMAIN_NAME"
  511. nginx_dissite "$POSTACTIV_DOMAIN_NAME"
  512. remove_certs "$POSTACTIV_DOMAIN_NAME"
  513. if [ -f /etc/cron.hourly/postactiv-daemons ]; then
  514. rm /etc/cron.hourly/postactiv-daemons
  515. fi
  516. if [ -f "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs/scripts/stopdaemons.sh" ]; then
  517. cd "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs" || exit 2467245248
  518. scripts/stopdaemons.sh
  519. fi
  520. kill_pid=$(pgrep "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs/scripts/queuedaemon.php" | head -n 1)
  521. kill -9 "$kill_pid"
  522. pkill "$POSTACTIV_DOMAIN_NAME/htdocs/scripts/queuedaemon.php"
  523. if [ -d "/var/www/$POSTACTIV_DOMAIN_NAME" ]; then
  524. rm -rf "/var/www/$POSTACTIV_DOMAIN_NAME"
  525. fi
  526. if [ -f "/etc/nginx/sites-available/$POSTACTIV_DOMAIN_NAME" ]; then
  527. rm "/etc/nginx/sites-available/$POSTACTIV_DOMAIN_NAME"
  528. fi
  529. function_check drop_database
  530. drop_database postactiv
  531. function_check remove_onion_service
  532. remove_onion_service postactiv ${POSTACTIV_ONION_PORT}
  533. if grep -q "postactiv" /etc/crontab; then
  534. sed -i "/postactiv/d" /etc/crontab
  535. fi
  536. remove_app postactiv
  537. remove_completion_param install_postactiv
  538. sed -i '/postactiv/d' "$COMPLETION_FILE"
  539. remove_backup_database_local postactiv
  540. sed -i '/postactiv-firewall/d' /etc/crontab
  541. sed -i 's|mysqli.allow_persistent.*|mysqli.allow_persistent = On|g' /etc/php/7.0/cli/php.ini
  542. sed -i 's|mysqli.reconnect.*|mysqli.reconnect = Off|g' /etc/php/7.0/cli/php.ini
  543. if [ -f /usr/bin/postactiv-firewall ]; then
  544. rm /usr/bin/postactiv-firewall
  545. fi
  546. if [ -f /etc/cron.daily/postactiv-expire ]; then
  547. rm /etc/cron.daily/postactiv-expire
  548. fi
  549. if [ -f /usr/bin/postactiv-expire-posts ]; then
  550. rm /usr/bin/postactiv-expire-posts
  551. fi
  552. function_check remove_ddns_domain
  553. remove_ddns_domain "$POSTACTIV_DOMAIN_NAME"
  554. }
  555. function install_postactiv_main {
  556. if [ ! "$POSTACTIV_DOMAIN_NAME" ]; then
  557. echo $'No domain name was given for postactiv'
  558. exit 7359
  559. fi
  560. if [[ $(app_is_installed postactiv_main) == "1" ]]; then
  561. return
  562. fi
  563. function_check postactiv_running_script
  564. postactiv_running_script
  565. function_check install_mariadb
  566. install_mariadb
  567. function_check get_mariadb_password
  568. get_mariadb_password
  569. function_check repair_databases_script
  570. repair_databases_script
  571. apt-get -yq install php-gettext php-curl php-gd php-mysql git curl
  572. apt-get -yq install memcached php-memcached php-intl exiftool libfcgi0ldbl
  573. apt-get -yq install php7.0-bcmath php7.0-curl php7.0-exif php7.0-gd
  574. apt-get -yq install php7.0-intl php7.0-mbstring php7.0-mysqlnd
  575. apt-get -yq install php7.0-opcache php7.0-readline php7.0-xmlwriter
  576. if [ ! -d "/var/www/$POSTACTIV_DOMAIN_NAME" ]; then
  577. mkdir "/var/www/$POSTACTIV_DOMAIN_NAME"
  578. fi
  579. if [ ! -d "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs" ]; then
  580. if [ -d /repos/postactiv ]; then
  581. mkdir "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs"
  582. cp -r -p /repos/postactiv/. "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs"
  583. cd "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs" || exit 46824682682
  584. git pull
  585. else
  586. # This is deliberately non-recursive
  587. git clone "$POSTACTIV_REPO" "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs"
  588. fi
  589. if [ ! -d "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs" ]; then
  590. echo $'Unable to clone postactiv repo'
  591. exit 87525
  592. fi
  593. fi
  594. cd "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs" || exit 46287462828
  595. git checkout $POSTACTIV_COMMIT -b $POSTACTIV_COMMIT
  596. set_completion_param "postactiv commit" "$POSTACTIV_COMMIT"
  597. chmod g+w "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs"
  598. chmod a+w "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs/avatar"
  599. chmod a+w "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs/file"
  600. chown -R www-data:www-data "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs"
  601. chmod +x "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs/scripts/maildaemon.php"
  602. chmod 755 "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs/extlib/HTMLPurifier/HTMLPurifier/DefinitionCache/Serializer.php"
  603. chmod -x "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs/extlib/HTMLPurifier/HTMLPurifier/DefinitionCache/Serializer.php"
  604. function_check postactiv_create_database
  605. postactiv_create_database
  606. if [ ! -f "/etc/aliases" ]; then
  607. touch /etc/aliases
  608. fi
  609. if ! grep -q "www-data: root" /etc/aliases; then
  610. echo 'www-data: root' >> /etc/aliases
  611. fi
  612. if ! grep -q "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs/scripts/maildaemon.php" /etc/aliases; then
  613. echo "*: /var/www/$POSTACTIV_DOMAIN_NAME/htdocs/scripts/maildaemon.php" >> /etc/aliases
  614. fi
  615. function_check add_ddns_domain
  616. add_ddns_domain "$POSTACTIV_DOMAIN_NAME"
  617. POSTACTIV_ONION_HOSTNAME=$(add_onion_service postactiv 80 ${POSTACTIV_ONION_PORT})
  618. postactiv_nginx_site=/etc/nginx/sites-available/$POSTACTIV_DOMAIN_NAME
  619. if [[ $ONION_ONLY == "no" ]]; then
  620. function_check nginx_http_redirect
  621. nginx_http_redirect "$POSTACTIV_DOMAIN_NAME" "index index.php"
  622. { echo 'server {';
  623. echo ' listen 443 ssl;';
  624. echo ' #listen [::]:443 ssl;';
  625. echo " server_name $POSTACTIV_DOMAIN_NAME;";
  626. echo ''; } >> "$postactiv_nginx_site"
  627. function_check nginx_compress
  628. nginx_compress "$POSTACTIV_DOMAIN_NAME"
  629. echo '' >> "$postactiv_nginx_site"
  630. echo ' # Security' >> "$postactiv_nginx_site"
  631. function_check nginx_ssl
  632. nginx_ssl "$POSTACTIV_DOMAIN_NAME"
  633. function_check nginx_security_options
  634. nginx_security_options "$POSTACTIV_DOMAIN_NAME"
  635. { echo ' add_header Strict-Transport-Security max-age=15768000;';
  636. echo '';
  637. echo ' # Logs';
  638. echo ' access_log /dev/null;';
  639. echo ' error_log /dev/null;';
  640. echo '';
  641. echo ' # Root';
  642. echo " root /var/www/$POSTACTIV_DOMAIN_NAME/htdocs;";
  643. echo '';
  644. echo ' # Index';
  645. echo ' index index.php;';
  646. echo '';
  647. echo ' # PHP';
  648. echo ' location ~ \.php {';
  649. echo ' client_max_body_size 50m;';
  650. echo ' client_body_buffer_size 50m;';
  651. echo ' include snippets/fastcgi-php.conf;';
  652. echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;';
  653. echo ' fastcgi_read_timeout 30;';
  654. echo ' }';
  655. echo '';
  656. echo ' # Location';
  657. echo ' location / {'; } >> "$postactiv_nginx_site"
  658. function_check nginx_limits
  659. nginx_limits "$POSTACTIV_DOMAIN_NAME" '15m'
  660. { echo " try_files \$uri \$uri/ @postactiv;";
  661. echo ' }';
  662. echo '';
  663. echo ' # Fancy URLs';
  664. echo ' location @postactiv {';
  665. echo ' client_max_body_size 50m;';
  666. echo ' client_body_buffer_size 50m;';
  667. echo " rewrite ^(.*)\$ /index.php?p=\$1 last;";
  668. echo ' }';
  669. echo '';
  670. echo ' # Restrict access that is unnecessary anyway';
  671. echo ' location ~ /\.(ht|git) {';
  672. echo ' deny all;';
  673. echo ' }';
  674. echo '}'; } >> "$postactiv_nginx_site"
  675. else
  676. echo -n '' > "$postactiv_nginx_site"
  677. fi
  678. { echo 'server {';
  679. echo " listen 127.0.0.1:$POSTACTIV_ONION_PORT default_server;";
  680. echo " server_name $POSTACTIV_ONION_HOSTNAME;";
  681. echo ''; } >> "$postactiv_nginx_site"
  682. function_check nginx_security_options
  683. nginx_security_options "$POSTACTIV_DOMAIN_NAME"
  684. echo '' >> "$postactiv_nginx_site"
  685. function_check nginx_compress
  686. nginx_compress "$POSTACTIV_DOMAIN_NAME"
  687. { echo '';
  688. echo ' # Logs';
  689. echo ' access_log /dev/null;';
  690. echo ' error_log /dev/null;';
  691. echo '';
  692. echo ' # Root';
  693. echo " root /var/www/$POSTACTIV_DOMAIN_NAME/htdocs;";
  694. echo '';
  695. echo ' # Index';
  696. echo ' index index.php;';
  697. echo '';
  698. echo ' # PHP';
  699. echo ' location ~ \.php {';
  700. echo ' client_max_body_size 50m;';
  701. echo ' client_body_buffer_size 50m;';
  702. echo ' include snippets/fastcgi-php.conf;';
  703. echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;';
  704. echo ' fastcgi_read_timeout 30;';
  705. echo ' }';
  706. echo '';
  707. echo ' # Location';
  708. echo ' location / {'; } >> "$postactiv_nginx_site"
  709. function_check nginx_limits
  710. nginx_limits "$POSTACTIV_DOMAIN_NAME" '15m'
  711. { echo " try_files \$uri \$uri/ @postactiv;";
  712. echo ' }';
  713. echo '';
  714. echo ' # Fancy URLs';
  715. echo ' location @postactiv {';
  716. echo ' client_max_body_size 50m;';
  717. echo ' client_body_buffer_size 50m;';
  718. echo " rewrite ^(.*)\$ /index.php?p=\$1 last;";
  719. echo ' }';
  720. echo '';
  721. echo ' # Restrict access that is unnecessary anyway';
  722. echo ' location ~ /\.(ht|git) {';
  723. echo ' deny all;';
  724. echo ' }';
  725. echo '}'; } >> "$postactiv_nginx_site"
  726. function_check gnusocial_set_limits
  727. gnusocial_set_limits "$postactiv_nginx_site"
  728. function_check configure_php
  729. configure_php
  730. function_check create_site_certificate
  731. create_site_certificate "$POSTACTIV_DOMAIN_NAME" 'yes'
  732. # Ensure that the database gets backed up locally, if remote
  733. # backups are not being used
  734. function_check backup_databases_script_header
  735. backup_databases_script_header
  736. function_check backup_database_local
  737. backup_database_local postactiv
  738. function_check nginx_ensite
  739. nginx_ensite "$POSTACTIV_DOMAIN_NAME"
  740. # NOTE: For the typical case always enable SSL and only
  741. # disable it if in onion only mode. This is due to complexities
  742. # with the way URLs are generated by postactiv
  743. postactiv_ssl='always'
  744. if [[ $ONION_ONLY != 'no' ]]; then
  745. postactiv_ssl='never'
  746. fi
  747. POSTACTIV_SERVER=${POSTACTIV_DOMAIN_NAME}
  748. if [[ $ONION_ONLY != 'no' ]]; then
  749. POSTACTIV_SERVER=${POSTACTIV_ONION_HOSTNAME}
  750. fi
  751. # Create the configuration
  752. postactiv_installer=/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/scripts/install_cli.php
  753. if [ ! -f "$postactiv_installer" ]; then
  754. rm -rf "/var/www/$POSTACTIV_DOMAIN_NAME"
  755. echo $'No postactiv commandline installer found'
  756. exit 53026
  757. fi
  758. ${postactiv_installer} --server "${POSTACTIV_SERVER}" \
  759. --host="localhost" --database="postactiv" \
  760. --dbtype=mysql --username="root" -v \
  761. --password="$MARIADB_PASSWORD" \
  762. --sitename=$"postactiv" --fancy='yes' \
  763. --admin-nick="$MY_USERNAME" \
  764. --admin-pass="$POSTACTIV_ADMIN_PASSWORD" \
  765. --site-profile="community" \
  766. --ssl=${postactiv_ssl}
  767. # There can be a lot of warnings here so the return value check is disabled
  768. #if [ ! "$?" = "0" ]; then
  769. # # failed to install
  770. # echo $'Could not install postactiv'
  771. # exit 72357
  772. #fi
  773. # check postactiv has a config file
  774. postactiv_config_file="/var/www/$POSTACTIV_DOMAIN_NAME/htdocs/config.php"
  775. if [ ! -f "$postactiv_config_file" ]; then
  776. drop_database postactiv
  777. rm -rf "/var/www/$POSTACTIV_DOMAIN_NAME"
  778. echo $'Postactiv config.php not found'
  779. exit 87586
  780. fi
  781. # Some useful settings
  782. if ! grep -q "Recommended postactiv settings" "$postactiv_config_file"; then
  783. { echo "";
  784. echo "// Recommended postactiv settings";
  785. echo "\$config['thumbnail']['maxsize'] = 3000;";
  786. echo "\$config['profile']['delete'] = true;";
  787. echo "\$config['profile']['changenick'] = true;";
  788. echo "\$config['public']['localonly'] = false;";
  789. echo "addPlugin('StoreRemoteMedia');";
  790. echo "\$config['queue']['enabled'] = true;";
  791. echo "\$config['queue']['daemon'] = true;";
  792. echo "\$config['ostatus']['hub_retries'] = 3;"; } >> "$postactiv_config_file"
  793. fi
  794. echo "\$config['mail']['domain'] = '${DEFAULT_DOMAIN_NAME}';" >> "$postactiv_config_file"
  795. # This improves performance
  796. sed -i "s|//\$config\\['db'\\]\\['schemacheck'\\].*|\$config\\['db'\\]\\['schemacheck'\\] = 'script';|g" "$postactiv_config_file"
  797. # remove the install script
  798. if [ -f "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs/install.php" ]; then
  799. rm "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs/install.php"
  800. fi
  801. # php configuration
  802. sed -i 's|mysqli.allow_persistent.*|mysqli.allow_persistent = On|g' /etc/php/7.0/cli/php.ini
  803. sed -i 's|mysqli.reconnect.*|mysqli.reconnect = On|g' /etc/php/7.0/cli/php.ini
  804. systemctl restart mariadb
  805. systemctl restart php7.0-fpm
  806. systemctl restart nginx
  807. "${PROJECT_NAME}-addemail" -u "$MY_USERNAME" -e "noreply@$POSTACTIV_DOMAIN_NAME" -g postactiv --public no
  808. "${PROJECT_NAME}-pass" -u "$MY_USERNAME" -a postactiv -p "$POSTACTIV_ADMIN_PASSWORD"
  809. gnusocial_block_user_script
  810. gnusocial_block_domain_script postactiv "$POSTACTIV_DOMAIN_NAME"
  811. set_completion_param "postactiv domain" "$POSTACTIV_DOMAIN_NAME"
  812. install_completed postactiv_main
  813. }
  814. function install_postactiv {
  815. if [[ "$ONION_ONLY" != 'no' ]]; then
  816. return
  817. fi
  818. install_postactiv_main
  819. install_qvitter "$POSTACTIV_DOMAIN_NAME" "postactiv"
  820. install_gnusocial_markdown "$POSTACTIV_DOMAIN_NAME" "postactiv"
  821. install_gnusocial_plugin_sharings "$POSTACTIV_DOMAIN_NAME" "postactiv"
  822. install_gnusocial_plugin_sharings_theme "$POSTACTIV_DOMAIN_NAME" "postactiv"
  823. # Currently Pleroma won't install on ARM systems
  824. # because it uses node-sass which doesn't support ARM
  825. if [[ "$(arch)" == "arm"* || "$(arch)" == "aarch"* ]]; then
  826. echo -m $'WARNING: Pleroma currently does not support ARM '
  827. echo $'architecture, so it will not be installed'
  828. else
  829. function_check install_nodejs
  830. install_nodejs pleroma-gnusocial
  831. install_pleroma_front_end "postactiv" "$POSTACTIV_DOMAIN_NAME" "$POSTACTIV_BACKGROUND_IMAGE_URL" "$POSTACTIV_TITLE"
  832. install_gnusocial_default_background "postactiv" "$POSTACTIV_DOMAIN_NAME"
  833. postactiv_customise_logo "$POSTACTIV_DOMAIN_NAME"
  834. sed -i 's|"theme":.*|"theme": "base16-harmonic16-light.css",|g' "/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/static/config.json"
  835. fi
  836. expire_gnusocial_posts "$POSTACTIV_DOMAIN_NAME" "postactiv" "$POSTACTIV_EXPIRE_MONTHS"
  837. # this has to be run as root initially, otherwise database tables
  838. # don't get created
  839. cd "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs" || exit 3658254254
  840. sh scripts/startdaemons.sh
  841. php scripts/checkschema.php
  842. /etc/cron.hourly/postactiv-daemons
  843. systemctl restart nginx
  844. # Set qvitter to be the default UI. It's probably the most stable.
  845. # And doesn't forget logins
  846. gnusocial_use_qvitter postactiv
  847. if [ "$POSTACTIV_BACKGROUND_IMAGE_URL" ]; then
  848. pleroma_set_background_image_from_url "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs" "$POSTACTIV_DOMAIN_NAME" "$POSTACTIV_BACKGROUND_IMAGE_URL" "$POSTACTIV_TITLE"
  849. fi
  850. APP_INSTALLED=1
  851. }
  852. # NOTE: deliberately there is no "exit 0"