freedombone-app-postactiv 37KB

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