freedombone-app-gnusocial 37KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973
  1. #!/bin/bash
  2. #
  3. # .---. . .
  4. # | | |
  5. # |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
  6. # | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
  7. # ' ' --' --' -' - -' ' ' -' -' -' ' - --'
  8. #
  9. # Freedom in the Cloud
  10. #
  11. # gnusocial application
  12. #
  13. # License
  14. # =======
  15. #
  16. # Copyright (C) 2014-2017 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. GNUSOCIAL_DOMAIN_NAME=
  34. GNUSOCIAL_CODE=
  35. GNUSOCIAL_ONION_PORT=8087
  36. GNUSOCIAL_REPO="https://git.gnu.io/gnu/gnu-social.git"
  37. GNUSOCIAL_COMMIT='1517deeeb621a0256106d0108855e8827713e2cc'
  38. GNUSOCIAL_ADMIN_PASSWORD=
  39. GNUSOCIAL_BACKGROUND_IMAGE_URL=
  40. GNUSOCIAL_MARKDOWN_REPO="https://git.gnu.io/chimo/markdown.git"
  41. GNUSOCIAL_MARKDOWN_COMMIT='03c53942f94b3376f0946e6e1fe566cc21ccf232'
  42. # Sharings plugin for gnusocial
  43. SHARINGS_REPO="http://git.lasindias.club/bashrc/Sharings"
  44. SHARINGS_COMMIT='d5c6c7f855d9afff9086c09ea706f38c859bc0d4'
  45. SHARINGS_THEME_REPO="http://git.lasindias.club/manuel/SharingsTheme"
  46. SHARINGS_THEME_COMMIT='7106c7ef03'
  47. GNUSOCIAL_TITLE='Pleroma FE'
  48. # Number of months after which posts expire
  49. GNUSOCIAL_EXPIRE_MONTHS=3
  50. gnusocial_variables=(ONION_ONLY
  51. GNUSOCIAL_DOMAIN_NAME
  52. GNUSOCIAL_CODE
  53. GNUSOCIAL_WELCOME_MESSAGE
  54. GNUSOCIAL_BACKGROUND_IMAGE_URL
  55. DDNS_PROVIDER
  56. GNUSOCIAL_MARKDOWN_REPO
  57. GNUSOCIAL_MARKDOWN_COMMIT
  58. SHARINGS_REPO
  59. SHARINGS_COMMIT
  60. SHARINGS_THEME_REPO
  61. SHARINGS_THEME_COMMIT
  62. GNUSOCIAL_TITLE
  63. GNUSOCIAL_EXPIRE_MONTHS
  64. MY_USERNAME)
  65. function gnusocial_fix_endless_reloads {
  66. # This fixes a bug introduced with commit 5f7032dfee1fd202c14e76a9f8b37af35d584901
  67. # and which causes OrFox to endlessly reload the page
  68. sed -i 's| && common_local_referer()||g' /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/lib/apiauthaction.php
  69. }
  70. function remove_user_gnusocial {
  71. remove_username="$1"
  72. ${PROJECT_NAME}-pass -u $remove_username --rmapp gnusocial
  73. function_check get_completion_param
  74. GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
  75. if [ -d /var/www/$GNUSOCIAL_DOMAIN_NAME ]; then
  76. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
  77. php scripts/deleteprofile.php -n $remove_username -y
  78. fi
  79. }
  80. function add_user_gnusocial {
  81. new_username="$1"
  82. new_user_password="$2"
  83. ${PROJECT_NAME}-pass -u $new_username -a gnusocial -p "$new_user_password"
  84. GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
  85. if [ -d /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs ]; then
  86. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
  87. php scripts/registeruser.php -n $new_username -w "$new_user_password" -e "$new_username@$HOSTNAME"
  88. ${PROJECT_NAME}-addemail -u $new_username -e "noreply@$GNUSOCIAL_DOMAIN_NAME" -g gnusocial --public no
  89. echo '0'
  90. else
  91. echo '1'
  92. fi
  93. }
  94. function install_interactive_gnusocial {
  95. if [ ! $ONION_ONLY ]; then
  96. ONION_ONLY='no'
  97. fi
  98. if [[ $ONION_ONLY != "no" ]]; then
  99. GNUSOCIAL_DOMAIN_NAME='gnusocial.local'
  100. else
  101. GNUSOCIAL_DETAILS_COMPLETE=
  102. while [ ! $GNUSOCIAL_DETAILS_COMPLETE ]
  103. do
  104. data=$(tempfile 2>/dev/null)
  105. trap "rm -f $data" 0 1 2 5 15
  106. if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
  107. dialog --backtitle $"Freedombone Configuration" \
  108. --title $"GNU Social Configuration" \
  109. --form $"\nPlease enter your GNU Social 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 'GNUSOCIAL_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 25 33 40 \
  111. $"Title:" 2 1 "$(grep '$GNUSOCIAL_TITLE' temp.cfg | awk -F '=' '{print $2}')" 2 25 255 255 \
  112. $"Background image URL:" 3 1 "$(grep '$GNUSOCIAL_BACKGROUND_IMAGE_URL' temp.cfg | awk -F '=' '{print $2}')" 3 25 255 255 \
  113. $"Code:" 4 1 "$(grep 'GNUSOCIAL_CODE' temp.cfg | awk -F '=' '{print $2}')" 4 25 33 255 \
  114. 2> $data
  115. else
  116. dialog --backtitle $"Freedombone Configuration" \
  117. --title $"GNU Social Configuration" \
  118. --form $"\nPlease enter your GNU Social 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 'GNUSOCIAL_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 25 33 40 \
  120. $"Title:" 2 1 "$(grep '$GNUSOCIAL_TITLE' temp.cfg | awk -F '=' '{print $2}')" 2 25 255 255 \
  121. $"Background image URL:" 3 1 "$(grep '$GNUSOCIAL_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) exit 1;;
  127. 255) exit 1;;
  128. esac
  129. GNUSOCIAL_DOMAIN_NAME=$(cat $data | sed -n 1p)
  130. title=$(cat $data | sed -n 2p)
  131. if [ ${#title} -gt 1 ]; then
  132. GNUSOCIAL_TITLE=$welcome_msg
  133. fi
  134. img_url=$(cat $data | sed -n 3p)
  135. if [ ${#img_url} -gt 1 ]; then
  136. GNUSOCIAL_BACKGROUND_IMAGE_URL=$img_url
  137. fi
  138. if [ $GNUSOCIAL_DOMAIN_NAME ]; then
  139. if [[ $GNUSOCIAL_DOMAIN_NAME == "$HUBZILLA_DOMAIN_NAME" ]]; then
  140. GNUSOCIAL_DOMAIN_NAME=""
  141. fi
  142. TEST_DOMAIN_NAME=$GNUSOCIAL_DOMAIN_NAME
  143. validate_domain_name
  144. if [[ $TEST_DOMAIN_NAME != $GNUSOCIAL_DOMAIN_NAME ]]; then
  145. GNUSOCIAL_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. GNUSOCIAL_CODE=$(cat $data | sed -n 4p)
  150. validate_freedns_code "$GNUSOCIAL_CODE"
  151. if [ ! $VALID_CODE ]; then
  152. GNUSOCIAL_DOMAIN_NAME=
  153. fi
  154. fi
  155. fi
  156. fi
  157. if [ $GNUSOCIAL_DOMAIN_NAME ]; then
  158. GNUSOCIAL_DETAILS_COMPLETE="yes"
  159. fi
  160. done
  161. # remove any invalid characters
  162. if [ ${#GNUSOCIAL_TITLE} -gt 0 ]; then
  163. new_title=$(echo "$GNUSOCIAL_TITLE" | sed "s|'||g")
  164. GNUSOCIAL_TITLE="$new_title"
  165. fi
  166. # save the results in the config file
  167. write_config_param "GNUSOCIAL_CODE" "$GNUSOCIAL_CODE"
  168. write_config_param "GNUSOCIAL_TITLE" "$GNUSOCIAL_TITLE"
  169. write_config_param "GNUSOCIAL_BACKGROUND_IMAGE_URL" "$GNUSOCIAL_BACKGROUND_IMAGE_URL"
  170. fi
  171. write_config_param "GNUSOCIAL_DOMAIN_NAME" "$GNUSOCIAL_DOMAIN_NAME"
  172. APP_INSTALLED=1
  173. }
  174. function change_password_gnusocial {
  175. curr_username="$1"
  176. new_user_password="$2"
  177. read_config_param 'GNUSOCIAL_DOMAIN_NAME'
  178. cd /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs/scripts
  179. php setpassword.php "$curr_username" "$new_user_password"
  180. ${PROJECT_NAME}-pass -u "$curr_username" -a gnusocial -p "$new_user_password"
  181. }
  182. function gnusocial_create_database {
  183. if [ -f $IMAGE_PASSWORD_FILE ]; then
  184. GNUSOCIAL_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
  185. else
  186. if [ ! $GNUSOCIAL_ADMIN_PASSWORD ]; then
  187. GNUSOCIAL_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
  188. fi
  189. fi
  190. if [ ! $GNUSOCIAL_ADMIN_PASSWORD ]; then
  191. return
  192. fi
  193. function_check create_database
  194. create_database gnusocial "$GNUSOCIAL_ADMIN_PASSWORD" $MY_USERNAME
  195. }
  196. function reconfigure_gnusocial {
  197. echo -n ''
  198. }
  199. function gnusocial_set_background_image {
  200. GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
  201. data=$(tempfile 2>/dev/null)
  202. trap "rm -f $data" 0 1 2 5 15
  203. dialog --title $"GNU Social" \
  204. --backtitle $"Freedombone Control Panel" \
  205. --inputbox $'Set a background image URL' 10 60 2>$data
  206. sel=$?
  207. case $sel in
  208. 0)
  209. temp_background=$(<$data)
  210. if [ ${#temp_background} -gt 0 ]; then
  211. GNUSOCIAL_BACKGROUND_IMAGE_URL="$temp_background"
  212. write_config_param "GNUSOCIAL_BACKGROUND_IMAGE_URL" "$GNUSOCIAL_BACKGROUND_IMAGE_URL"
  213. if [[ $(pleroma_set_background_image_from_url "$GNUSOCIAL_DOMAIN_NAME" "$GNUSOCIAL_BACKGROUND_IMAGE_URL" "$GNUSOCIAL_TITLE" | tail -n 1) == "0" ]]; then
  214. dialog --title $"Set GNU Social login background" \
  215. --msgbox $"The background image has been set" 6 60
  216. fi
  217. fi
  218. ;;
  219. esac
  220. }
  221. function gnusocial_set_title {
  222. data=$(tempfile 2>/dev/null)
  223. trap "rm -f $data" 0 1 2 5 15
  224. dialog --title $"GNU Social" \
  225. --backtitle $"Freedombone Control Panel" \
  226. --inputbox $'Set a title' 10 60 2>$data
  227. sel=$?
  228. case $sel in
  229. 0)
  230. new_title=$(<$data)
  231. if [ ${#new_title} -gt 0 ]; then
  232. GNUSOCIAL_TITLE="$new_title"
  233. GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
  234. write_config_param "GNUSOCIAL_TITLE" "$GNUSOCIAL_TITLE"
  235. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/static
  236. sed -i "s|\"name\":.*|\"name\": \"${GNUSOCIAL_TITLE}\",|g" config.json
  237. dialog --title $"Set GNU Social title" \
  238. --msgbox $"The title has been set" 6 60
  239. fi
  240. ;;
  241. esac
  242. }
  243. function gnusocial_set_expire_months {
  244. GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
  245. read_config_param "GNUSOCIAL_EXPIRE_MONTHS"
  246. data=$(tempfile 2>/dev/null)
  247. trap "rm -f $data" 0 1 2 5 15
  248. dialog --title $"GNU Social" \
  249. --backtitle $"Freedombone Control Panel" \
  250. --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 "$GNUSOCIAL_EXPIRE_MONTHS" 2>$data
  251. sel=$?
  252. case $sel in
  253. 0)
  254. new_expiry_months=$(<$data)
  255. if [ ${#new_expiry_months} -gt 0 ]; then
  256. # should contain no spaces
  257. if [[ "$new_expiry_months" == *" "* ]]; then
  258. return
  259. fi
  260. # should be a number
  261. re='^[0-9]+$'
  262. if ! [[ $new_expiry_months =~ $re ]] ; then
  263. return
  264. fi
  265. # set the new value
  266. GNUSOCIAL_EXPIRE_MONTHS=$new_expiry_months
  267. write_config_param "GNUSOCIAL_EXPIRE_MONTHS" "$GNUSOCIAL_EXPIRE_MONTHS"
  268. expire_gnusocial_posts "$GNUSOCIAL_DOMAIN_NAME" "gnusocial" "$GNUSOCIAL_EXPIRE_MONTHS"
  269. dialog --title $"Set GNU Social post expiry period" \
  270. --msgbox $"Expiry period set to $GNUSOCIAL_EXPIRE_MONTHS months" 6 60
  271. fi
  272. ;;
  273. esac
  274. }
  275. function configure_interactive_gnusocial {
  276. while true
  277. do
  278. data=$(tempfile 2>/dev/null)
  279. trap "rm -f $data" 0 1 2 5 15
  280. dialog --backtitle $"Freedombone Control Panel" \
  281. --title $"GNU Social" \
  282. --radiolist $"Choose an operation:" 17 70 8 \
  283. 1 $"Set a background image" off \
  284. 2 $"Set the title" off \
  285. 3 $"Set post expiry period (currently $GNUSOCIAL_EXPIRE_MONTHS months)" off \
  286. 4 $"Select Qvitter user interface" off \
  287. 5 $"Select Pleroma user interface" off \
  288. 6 $"Select Classic user interface" off \
  289. 7 $"Select Armadillo user interface" off \
  290. 8 $"Exit" on 2> $data
  291. sel=$?
  292. case $sel in
  293. 1) return;;
  294. 255) return;;
  295. esac
  296. case $(cat $data) in
  297. 1) gnusocial_set_background_image;;
  298. 2) gnusocial_set_title;;
  299. 3) gnusocial_set_expire_months;;
  300. 4) gnusocial_use_qvitter gnusocial;;
  301. 5) gnusocial_use_pleroma gnusocial;;
  302. 6) gnusocial_use_classic gnusocial;;
  303. 7) gnusocial_use_armadillo gnusocial;;
  304. 8) break;;
  305. esac
  306. done
  307. }
  308. function upgrade_gnusocial {
  309. if grep -q "gnusocial domain" $COMPLETION_FILE; then
  310. GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
  311. fi
  312. # update to the next commit
  313. function_check set_repo_commit
  314. set_repo_commit /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs "gnusocial commit" "$GNUSOCIAL_COMMIT" $GNUSOCIAL_REPO
  315. gnusocial_fix_endless_reloads
  316. # Ensure that installation script is removed
  317. if [ -f /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/install.php ]; then
  318. rm /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/install.php
  319. fi
  320. if [ -d $INSTALL_DIR/pleroma ]; then
  321. if [ -f /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs/index.php ]; then
  322. mv /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs/index.php /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs/index_qvitter.php
  323. fi
  324. fi
  325. gnusocial_block_user_script
  326. gnusocial_block_domain_script gnusocial $GNUSOCIAL_DOMAIN_NAME
  327. gnusocial_hourly_script gnusocial $GNUSOCIAL_DOMAIN_NAME
  328. upgrade_pleroma "$GNUSOCIAL_DOMAIN_NAME" "gnusocial" "$GNUSOCIAL_BACKGROUND_IMAGE_URL" "$GNUSOCIAL_TITLE"
  329. install_gnusocial_default_background "gnusocial" "$GNUSOCIAL_DOMAIN_NAME"
  330. chown -R www-data:www-data /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs
  331. }
  332. function backup_local_gnusocial {
  333. GNUSOCIAL_DOMAIN_NAME='gnusocial'
  334. if grep -q "gnusocial domain" $COMPLETION_FILE; then
  335. GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
  336. fi
  337. source_directory=/var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs
  338. if [ -d $source_directory ]; then
  339. dest_directory=gnusocial
  340. function_check suspend_site
  341. suspend_site ${GNUSOCIAL_DOMAIN_NAME}
  342. function_check backup_directory_to_usb
  343. backup_directory_to_usb $source_directory $dest_directory
  344. function_check backup_database_to_usb
  345. backup_database_to_usb gnusocial
  346. function_check restart_site
  347. restart_site
  348. fi
  349. }
  350. function restore_local_gnusocial {
  351. if ! grep -q "gnusocial domain" $COMPLETION_FILE; then
  352. return
  353. fi
  354. GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
  355. if [ $GNUSOCIAL_DOMAIN_NAME ]; then
  356. echo $"Restoring gnusocial"
  357. temp_restore_dir=/root/tempgnusocial
  358. gnusocial_dir=/var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs
  359. # stop the daemons
  360. cd $gnusocial_dir
  361. su -c "sh scripts/stopdaemons.sh" -s /bin/sh www-data
  362. function_check gnusocial_create_database
  363. gnusocial_create_database
  364. restore_database gnusocial ${GNUSOCIAL_DOMAIN_NAME}
  365. if [ -d $temp_restore_dir ]; then
  366. rm -rf $temp_restore_dir
  367. fi
  368. # start the daemons
  369. cd $gnusocial_dir
  370. su -c "sh scripts/startdaemons.sh" -s /bin/sh www-data
  371. echo $"Restore of gnusocial complete"
  372. fi
  373. }
  374. function backup_remote_gnusocial {
  375. if grep -q "gnusocial domain" $COMPLETION_FILE; then
  376. GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
  377. temp_backup_dir=/var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs
  378. if [ -d $temp_backup_dir ]; then
  379. function_check suspend_site
  380. suspend_site ${GNUSOCIAL_DOMAIN_NAME}
  381. function_check backup_database_to_friend
  382. backup_database_to_friend gnusocial
  383. echo $"Backing up GNU social installation"
  384. function_check backup_directory_to_friend
  385. backup_directory_to_friend $temp_backup_dir gnusocial
  386. function_check restart_site
  387. restart_site
  388. else
  389. echo $"gnusocial domain specified but not found in ${temp_backup_dir}"
  390. fi
  391. fi
  392. }
  393. function restore_remote_gnusocial {
  394. if grep -q "gnusocial domain" $COMPLETION_FILE; then
  395. echo $"Restoring gnusocial"
  396. GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
  397. # stop the daemons
  398. cd /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs
  399. su -c "sh scripts/stopdaemons.sh" -s /bin/sh www-data
  400. function_check gnusocial_create_database
  401. gnusocial_create_database
  402. function_check restore_database_from_friend
  403. restore_database_from_friend gnusocial ${GNUSOCIAL_DOMAIN_NAME}
  404. if [ -d /root/tempgnusocial ]; then
  405. rm -rf /root/tempgnusocial
  406. fi
  407. # start the daemons
  408. cd /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs
  409. su -c "sh scripts/startdaemons.sh" -s /bin/sh www-data
  410. echo $"Restore of gnusocial complete"
  411. fi
  412. }
  413. function remove_gnusocial {
  414. if [ ${#GNUSOCIAL_DOMAIN_NAME} -eq 0 ]; then
  415. return
  416. fi
  417. function_check remove_nodejs
  418. remove_nodejs pleroma-gnusocial
  419. read_config_param "GNUSOCIAL_DOMAIN_NAME"
  420. read_config_param "MY_USERNAME"
  421. echo "Removing $GNUSOCIAL_DOMAIN_NAME"
  422. nginx_dissite $GNUSOCIAL_DOMAIN_NAME
  423. remove_certs $GNUSOCIAL_DOMAIN_NAME
  424. if [ -f /etc/cron.hourly/gnusocial-daemons ]; then
  425. rm /etc/cron.hourly/gnusocial-daemons
  426. fi
  427. if [ -f /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/scripts/stopdaemons.sh ]; then
  428. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/scripts
  429. su -c "sh scripts/stopdaemons.sh" -s /bin/sh www-data
  430. fi
  431. kill_pid=$(ps aux | grep /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/scripts/queuedaemon.php | awk -F ' ' '{print $2}' | head -n 1)
  432. kill -9 $kill_pid
  433. if [ -d /var/www/$GNUSOCIAL_DOMAIN_NAME ]; then
  434. rm -rf /var/www/$GNUSOCIAL_DOMAIN_NAME
  435. fi
  436. if [ -f /etc/nginx/sites-available/$GNUSOCIAL_DOMAIN_NAME ]; then
  437. rm /etc/nginx/sites-available/$GNUSOCIAL_DOMAIN_NAME
  438. fi
  439. function_check drop_database
  440. drop_database gnusocial
  441. function_check remove_onion_service
  442. remove_onion_service gnusocial ${GNUSOCIAL_ONION_PORT}
  443. if grep -q "gnusocial" /etc/crontab; then
  444. sed -i "/gnusocial/d" /etc/crontab
  445. fi
  446. remove_app gnusocial
  447. remove_completion_param install_gnusocial
  448. sed -i '/gnusocial/d' $COMPLETION_FILE
  449. remove_backup_database_local gnusocial
  450. sed -i '/gnusocial-firewall/d' /etc/crontab
  451. function_check remove_ddns_domain
  452. remove_ddns_domain $GNUSOCIAL_DOMAIN_NAME
  453. }
  454. function install_gnusocial_main {
  455. if [ ! $GNUSOCIAL_DOMAIN_NAME ]; then
  456. echo $'No domain name was given for gnusocial'
  457. exit 7359
  458. fi
  459. if [[ $(app_is_installed gnusocial_main) == "1" ]]; then
  460. return
  461. fi
  462. gnusocial_hourly_script gnusocial $GNUSOCIAL_DOMAIN_NAME
  463. function_check install_mariadb
  464. install_mariadb
  465. function_check get_mariadb_password
  466. get_mariadb_password
  467. function_check repair_databases_script
  468. repair_databases_script
  469. apt-get -yq install php-gettext php-curl php-gd php-mysql git curl
  470. apt-get -yq install php-memcached php-intl exiftool
  471. if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME ]; then
  472. mkdir /var/www/$GNUSOCIAL_DOMAIN_NAME
  473. fi
  474. if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs ]; then
  475. function_check git_clone
  476. git_clone $GNUSOCIAL_REPO /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
  477. if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs ]; then
  478. echo $'Unable to clone gnusocial repo'
  479. exit 87525
  480. fi
  481. fi
  482. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
  483. git checkout $GNUSOCIAL_COMMIT -b $GNUSOCIAL_COMMIT
  484. set_completion_param "gnusocial commit" "$GNUSOCIAL_COMMIT"
  485. gnusocial_fix_endless_reloads
  486. chmod g+w /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
  487. chmod a+w /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/avatar
  488. chmod a+w /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/file
  489. chown -R www-data:www-data /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
  490. chmod +x /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/scripts/maildaemon.php
  491. function_check gnusocial_create_database
  492. gnusocial_create_database
  493. if [ ! -f "/etc/aliases" ]; then
  494. touch /etc/aliases
  495. fi
  496. if ! grep -q "www-data: root" /etc/aliases; then
  497. echo 'www-data: root' >> /etc/aliases
  498. fi
  499. if ! grep -q "/var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/scripts/maildaemon.php" /etc/aliases; then
  500. echo "*: /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/scripts/maildaemon.php" >> /etc/aliases
  501. fi
  502. function_check add_ddns_domain
  503. add_ddns_domain $GNUSOCIAL_DOMAIN_NAME
  504. gnusocial_nginx_site=/etc/nginx/sites-available/$GNUSOCIAL_DOMAIN_NAME
  505. if [[ $ONION_ONLY == "no" ]]; then
  506. function_check nginx_http_redirect
  507. nginx_http_redirect $GNUSOCIAL_DOMAIN_NAME "index index.php"
  508. echo 'server {' >> $gnusocial_nginx_site
  509. echo ' listen 443 ssl;' >> $gnusocial_nginx_site
  510. echo ' listen [::]:443 ssl;' >> $gnusocial_nginx_site
  511. echo " server_name $GNUSOCIAL_DOMAIN_NAME;" >> $gnusocial_nginx_site
  512. echo '' >> $gnusocial_nginx_site
  513. function_check nginx_compress
  514. nginx_compress $GNUSOCIAL_DOMAIN_NAME
  515. echo '' >> $gnusocial_nginx_site
  516. echo ' # Security' >> $gnusocial_nginx_site
  517. function_check nginx_ssl
  518. nginx_ssl $GNUSOCIAL_DOMAIN_NAME
  519. function_check nginx_disable_sniffing
  520. nginx_disable_sniffing $GNUSOCIAL_DOMAIN_NAME
  521. echo ' add_header Strict-Transport-Security max-age=15768000;' >> $gnusocial_nginx_site
  522. echo '' >> $gnusocial_nginx_site
  523. echo ' # Logs' >> $gnusocial_nginx_site
  524. echo ' access_log /dev/null;' >> $gnusocial_nginx_site
  525. echo ' error_log /dev/null;' >> $gnusocial_nginx_site
  526. echo '' >> $gnusocial_nginx_site
  527. echo ' # Root' >> $gnusocial_nginx_site
  528. echo " root /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs;" >> $gnusocial_nginx_site
  529. echo '' >> $gnusocial_nginx_site
  530. echo ' # Index' >> $gnusocial_nginx_site
  531. echo ' index index.php;' >> $gnusocial_nginx_site
  532. echo '' >> $gnusocial_nginx_site
  533. echo ' # PHP' >> $gnusocial_nginx_site
  534. echo ' location ~ \.php {' >> $gnusocial_nginx_site
  535. echo ' include snippets/fastcgi-php.conf;' >> $gnusocial_nginx_site
  536. echo ' fastcgi_pass unix:/var/run/php-fpm.sock;' >> $gnusocial_nginx_site
  537. echo ' }' >> $gnusocial_nginx_site
  538. echo '' >> $gnusocial_nginx_site
  539. echo ' # Location' >> $gnusocial_nginx_site
  540. echo ' location / {' >> $gnusocial_nginx_site
  541. function_check nginx_limits
  542. nginx_limits $GNUSOCIAL_DOMAIN_NAME '15m'
  543. echo ' try_files $uri $uri/ @gnusocial;' >> $gnusocial_nginx_site
  544. echo ' }' >> $gnusocial_nginx_site
  545. echo '' >> $gnusocial_nginx_site
  546. echo ' # Fancy URLs' >> $gnusocial_nginx_site
  547. echo ' location @gnusocial {' >> $gnusocial_nginx_site
  548. echo ' rewrite ^(.*)$ /index.php?p=$1 last;' >> $gnusocial_nginx_site
  549. echo ' }' >> $gnusocial_nginx_site
  550. echo '' >> $gnusocial_nginx_site
  551. echo ' # Restrict access that is unnecessary anyway' >> $gnusocial_nginx_site
  552. echo ' location ~ /\.(ht|git) {' >> $gnusocial_nginx_site
  553. echo ' deny all;' >> $gnusocial_nginx_site
  554. echo ' }' >> $gnusocial_nginx_site
  555. echo '' >> $gnusocial_nginx_site
  556. # DO NOT ENABLE KEYBASE. gnusocial really doesn't like having a .well-known directory
  557. echo '}' >> $gnusocial_nginx_site
  558. else
  559. echo -n '' > $gnusocial_nginx_site
  560. fi
  561. echo 'server {' >> $gnusocial_nginx_site
  562. echo " listen 127.0.0.1:$GNUSOCIAL_ONION_PORT default_server;" >> $gnusocial_nginx_site
  563. echo " server_name $GNUSOCIAL_DOMAIN_NAME;" >> $gnusocial_nginx_site
  564. echo '' >> $gnusocial_nginx_site
  565. function_check nginx_compress
  566. nginx_compress $GNUSOCIAL_DOMAIN_NAME
  567. echo '' >> $gnusocial_nginx_site
  568. function_check nginx_disable_sniffing
  569. nginx_disable_sniffing $GNUSOCIAL_DOMAIN_NAME
  570. echo '' >> $gnusocial_nginx_site
  571. echo ' # Logs' >> $gnusocial_nginx_site
  572. echo ' access_log /dev/null;' >> $gnusocial_nginx_site
  573. echo ' error_log /dev/null;' >> $gnusocial_nginx_site
  574. echo '' >> $gnusocial_nginx_site
  575. echo ' # Root' >> $gnusocial_nginx_site
  576. echo " root /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs;" >> $gnusocial_nginx_site
  577. echo '' >> $gnusocial_nginx_site
  578. echo ' # Index' >> $gnusocial_nginx_site
  579. echo ' index index.php;' >> $gnusocial_nginx_site
  580. echo '' >> $gnusocial_nginx_site
  581. echo ' # PHP' >> $gnusocial_nginx_site
  582. echo ' location ~ \.php {' >> $gnusocial_nginx_site
  583. echo ' include snippets/fastcgi-php.conf;' >> $gnusocial_nginx_site
  584. echo ' fastcgi_pass unix:/var/run/php-fpm.sock;' >> $gnusocial_nginx_site
  585. echo ' }' >> $gnusocial_nginx_site
  586. echo '' >> $gnusocial_nginx_site
  587. echo ' # Location' >> $gnusocial_nginx_site
  588. echo ' location / {' >> $gnusocial_nginx_site
  589. function_check nginx_limits
  590. nginx_limits $GNUSOCIAL_DOMAIN_NAME '15m'
  591. echo ' try_files $uri $uri/ @gnusocial;' >> $gnusocial_nginx_site
  592. echo ' }' >> $gnusocial_nginx_site
  593. echo '' >> $gnusocial_nginx_site
  594. echo ' # Fancy URLs' >> $gnusocial_nginx_site
  595. echo ' location @gnusocial {' >> $gnusocial_nginx_site
  596. echo ' rewrite ^(.*)$ /index.php?p=$1 last;' >> $gnusocial_nginx_site
  597. echo ' }' >> $gnusocial_nginx_site
  598. echo '' >> $gnusocial_nginx_site
  599. echo ' # Restrict access that is unnecessary anyway' >> $gnusocial_nginx_site
  600. echo ' location ~ /\.(ht|git) {' >> $gnusocial_nginx_site
  601. echo ' deny all;' >> $gnusocial_nginx_site
  602. echo ' }' >> $gnusocial_nginx_site
  603. echo '' >> $gnusocial_nginx_site
  604. # DO NOT ENABLE KEYBASE. gnusocial really doesn't like having a .well-known directory
  605. echo '}' >> $gnusocial_nginx_site
  606. function_check configure_php
  607. configure_php
  608. function_check create_site_certificate
  609. create_site_certificate $GNUSOCIAL_DOMAIN_NAME 'yes'
  610. # Ensure that the database gets backed up locally, if remote
  611. # backups are not being used
  612. function_check backup_databases_script_header
  613. backup_databases_script_header
  614. function_check backup_database_local
  615. backup_database_local gnusocial
  616. function_check nginx_ensite
  617. nginx_ensite $GNUSOCIAL_DOMAIN_NAME
  618. # NOTE: For the typical case always enable SSL and only
  619. # disable it if in onion only mode. This is due to complexities
  620. # with the way URLs are generated by gnusocial
  621. gnusocial_ssl='always'
  622. if [[ $ONION_ONLY != 'no' ]]; then
  623. gnusocial_ssl='never'
  624. fi
  625. GNUSOCIAL_ONION_HOSTNAME=$(add_onion_service gnusocial 80 ${GNUSOCIAL_ONION_PORT})
  626. GNUSOCIAL_SERVER=${GNUSOCIAL_DOMAIN_NAME}
  627. if [[ $ONION_ONLY != 'no' ]]; then
  628. GNUSOCIAL_SERVER=${GNUSOCIAL_ONION_HOSTNAME}
  629. fi
  630. # Create the configuration
  631. gnusocial_installer=/var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs/scripts/install_cli.php
  632. if [ ! -f $gnusocial_installer ]; then
  633. rm -rf /var/www/$GNUSOCIAL_DOMAIN_NAME
  634. echo $'No gnusocial commandline installer found'
  635. exit 53026
  636. fi
  637. ${gnusocial_installer} --server "${GNUSOCIAL_SERVER}" \
  638. --host="localhost" --database="gnusocial" \
  639. --dbtype=mysql --username="root" -v \
  640. --password="$MARIADB_PASSWORD" \
  641. --sitename=$"GNU Social" --fancy='yes' \
  642. --admin-nick="$MY_USERNAME" \
  643. --admin-pass="$GNUSOCIAL_ADMIN_PASSWORD" \
  644. --site-profile="community" \
  645. --ssl=${gnusocial_ssl}
  646. # There can be a lot of warnings here so the return value check is disabled
  647. #if [ ! "$?" = "0" ]; then
  648. # # failed to install
  649. # echo $'Could not install GNU Social'
  650. # exit 72357
  651. #fi
  652. # check gnusocial has a config file
  653. gnusocial_config_file=/var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/config.php
  654. if [ ! -f $gnusocial_config_file ]; then
  655. drop_database gnusocial
  656. rm -rf /var/www/$GNUSOCIAL_DOMAIN_NAME
  657. echo $'Gnusocial config.php not found'
  658. exit 87586
  659. fi
  660. # Some useful settings
  661. if ! grep -q "Recommended GNU social settings" $gnusocial_config_file; then
  662. echo "" >> $gnusocial_config_file
  663. echo "// Recommended GNU social settings" >> $gnusocial_config_file
  664. echo "\$config['thumbnail']['maxsize'] = 3000;" >> $gnusocial_config_file
  665. echo "\$config['profile']['delete'] = true;" >> $gnusocial_config_file
  666. echo "\$config['profile']['changenick'] = true;" >> $gnusocial_config_file
  667. echo "\$config['public']['localonly'] = false;" >> $gnusocial_config_file
  668. echo "addPlugin('StoreRemoteMedia');" >> $gnusocial_config_file
  669. echo "\$config['queue']['enabled'] = true;" >> $gnusocial_config_file
  670. echo "\$config['queue']['daemon'] = true;" >> $gnusocial_config_file
  671. echo "\$config['ostatus']['hub_retries'] = 3;" >> $gnusocial_config_file
  672. fi
  673. # turn off logging
  674. echo "\$config['site']['logfile'] = '/dev/null';" >> $gnusocial_config_file
  675. echo "\$config['mail']['domain'] = '${DEFAULT_DOMAIN_NAME}';" >> $gnusocial_config_file
  676. # This improves performance
  677. sed -i "s|//\$config\['db'\]\['schemacheck'\].*|\$config\['db'\]\['schemacheck'\] = 'script';|g" $gnusocial_config_file
  678. systemctl restart php7.0-fpm
  679. systemctl restart nginx
  680. ${PROJECT_NAME}-addemail -u $MY_USERNAME -e "noreply@$GNUSOCIAL_DOMAIN_NAME" -g gnusocial --public no
  681. ${PROJECT_NAME}-pass -u $MY_USERNAME -a gnusocial -p "$GNUSOCIAL_ADMIN_PASSWORD"
  682. gnusocial_block_user_script
  683. gnusocial_block_domain_script gnusocial "$GNUSOCIAL_DOMAIN_NAME"
  684. set_completion_param "gnusocial domain" "$GNUSOCIAL_DOMAIN_NAME"
  685. install_completed gnusocial_main
  686. }
  687. function install_gnusocial_plugin_sharings {
  688. if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins ]; then
  689. echo $'No local/plugins directory found for the gnusocial'
  690. exit 72945
  691. fi
  692. apt-get -yq install liblocale-msgfmt-perl gettext
  693. # update to the next commit
  694. function_check set_repo_commit
  695. set_repo_commit /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins "gnusocial sharings plugin commit" "$SHARINGS_COMMIT" $SHARINGS_REPO
  696. if [[ $(app_is_installed gnusocial_plugin_sharings) == "1" ]]; then
  697. return
  698. fi
  699. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins
  700. function_check git_clone
  701. git_clone $SHARINGS_REPO Sharings
  702. if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings ]; then
  703. echo $'Unable to clone gnusocial sharings plugin'
  704. exit 36738
  705. fi
  706. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings
  707. git stash
  708. git checkout master
  709. git branch -D $SHARINGS_COMMIT
  710. git checkout $SHARINGS_COMMIT -b $SHARINGS_COMMIT
  711. # enable the plugin
  712. if ! grep -q "addPlugin('Sharings');" /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/config.php; then
  713. echo "addPlugin('Sharings');" >> /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/config.php
  714. fi
  715. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
  716. php scripts/checkschema.php
  717. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings
  718. php scripts/seedsharings.php
  719. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
  720. php scripts/upgrade.php
  721. php scripts/checkschema.php
  722. # Languages
  723. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings/locale/en/LC_MESSAGES
  724. msgfmt -o Sharings.mo Sharings.po
  725. if [ ! -f Sharings.po ]; then
  726. echo $'English translations for gnusocial sharings plugin were not created'
  727. exit 84352
  728. fi
  729. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings/locale/en_GB/LC_MESSAGES
  730. msgfmt -o Sharings.mo Sharings.po
  731. if [ ! -f Sharings.po ]; then
  732. echo $'English (GB) translations for gnusocial sharings plugin were not created'
  733. exit 84352
  734. fi
  735. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings/locale/en_US/LC_MESSAGES
  736. msgfmt -o Sharings.mo Sharings.po
  737. if [ ! -f Sharings.po ]; then
  738. echo $'English (US) translations for gnusocial sharings plugin were not created'
  739. exit 84352
  740. fi
  741. # Looks like this update function isn't supported by the current php version
  742. sed -i 's|ActivityVerb::UPDATE, ||g' /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings/SharingsPlugin.php
  743. chown -R www-data:www-data /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
  744. set_completion_param gnusocial "sharings plugin commit" "$SHARINGS_COMMIT"
  745. install_completed gnusocial_plugin_sharings
  746. }
  747. function install_gnusocial_plugin_sharings_theme {
  748. if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins ]; then
  749. echo $'No local/plugins directory found for the gnusocial'
  750. exit 74458
  751. fi
  752. # update to the next commit
  753. function_check set_repo_commit
  754. set_repo_commit /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins "gnusocial sharings theme plugin commit" "$SHARINGS_THEME_COMMIT" $SHARINGS_THEME_REPO
  755. if [[ $(app_is_installed gnusocial_plugin_sharings_theme) == "1" ]]; then
  756. return
  757. fi
  758. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins
  759. function_check git_clone
  760. git_clone $SHARINGS_THEME_REPO SharingsTheme
  761. if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/SharingsTheme ]; then
  762. echo $'Unable to clone gnusocial sharings plugin theme'
  763. exit 639253
  764. fi
  765. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/SharingsTheme
  766. git stash
  767. git checkout master
  768. git branch -D $SHARINGS_THEME_COMMIT
  769. git checkout $SHARINGS_THEME_COMMIT -b $SHARINGS_THEME_COMMIT
  770. # enable the plugin
  771. if ! grep -q "addPlugin('SharingsTheme');" /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/config.php; then
  772. echo "addPlugin('SharingsTheme');" >> /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/config.php
  773. fi
  774. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
  775. php scripts/checkschema.php
  776. chown -R www-data:www-data /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
  777. set_completion_param "gnusocial sharings plugin theme commit" "$SHARINGS_THEME_COMMIT"
  778. install_completed gnusocial_plugin_sharings_theme
  779. }
  780. function install_gnusocial_markdown {
  781. GNUSOCIAL_PATH=/var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
  782. # update to the next commit
  783. function_check set_repo_commit
  784. set_repo_commit $GNUSOCIAL_PATH/local/plugins/Markdown "gnusocial Markdown commit" "$GNUSOCIAL_MARKDOWN_COMMIT" $GNUSOCIAL_MARKDOWN_REPO
  785. if [[ $(app_is_installed gnusocial_markdown) == "1" ]]; then
  786. return
  787. fi
  788. if [ -d $GNUSOCIAL_PATH/local/plugins/Markdown ]; then
  789. rm -rf $GNUSOCIAL_PATH/local/plugins/Markdown
  790. fi
  791. if [ ! -d $GNUSOCIAL_PATH/local/plugins ]; then
  792. mkdir -p $GNUSOCIAL_PATH/local/plugins
  793. fi
  794. cd $GNUSOCIAL_PATH/local/plugins
  795. function_check git_clone
  796. git_clone $GNUSOCIAL_MARKDOWN_REPO Markdown
  797. cd $GNUSOCIAL_PATH/local/plugins/Markdown
  798. git checkout $GNUSOCIAL_MARKDOWN_COMMIT -b $GNUSOCIAL_MARKDOWN_COMMIT
  799. gnusocial_config_file=$GNUSOCIAL_PATH/config.php
  800. if ! grep -q "addPlugin('Markdown'" $gnusocial_config_file; then
  801. echo "" >> $gnusocial_config_file
  802. echo "// Markdown settings" >> $gnusocial_config_file
  803. echo "addPlugin('Markdown');" >> $gnusocial_config_file
  804. fi
  805. set_completion_param "gnusocial markdown commit" "$GNUSOCIAL_MARKDOWN_COMMIT"
  806. chown -R www-data:www-data $GNUSOCIAL_PATH
  807. install_completed gnusocial_markdown
  808. }
  809. function install_gnusocial {
  810. if [ ! $ONION_ONLY ]; then
  811. ONION_ONLY='no'
  812. fi
  813. install_gnusocial_main
  814. expire_gnusocial_posts "$GNUSOCIAL_DOMAIN_NAME" "gnusocial" "$GNUSOCIAL_EXPIRE_MONTHS"
  815. install_qvitter "$GNUSOCIAL_DOMAIN_NAME" "gnusocial"
  816. install_gnusocial_markdown
  817. #install_gnusocial_plugin_sharings
  818. #install_gnusocial_plugin_sharings_theme
  819. # Currently Pleroma won't install on ARM systems
  820. # because it uses node-sass which doesn't support ARM
  821. if [[ "$(arch)" == "arm"* ]]; then
  822. echo -m $'WARNING: Pleroma currently does not support ARM '
  823. echo $'architecture, so it will not be installed'
  824. else
  825. function_check install_nodejs
  826. install_nodejs pleroma-gnusocial
  827. install_pleroma_front_end "gnusocial" "$GNUSOCIAL_DOMAIN_NAME" "$GNUSOCIAL_BACKGROUND_IMAGE_URL" "$GNUSOCIAL_TITLE"
  828. install_gnusocial_default_background "gnusocial" "$GNUSOCIAL_DOMAIN_NAME"
  829. sed -i 's|"theme":.*|"theme": "base16-apathy.css",|g' /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs/static/config.json
  830. fi
  831. # unleash the daemons!
  832. /etc/cron.hourly/gnusocial-daemons
  833. systemctl restart nginx
  834. APP_INSTALLED=1
  835. }
  836. # NOTE: deliberately there is no "exit 0"