freedombone-app-gnusocial 37KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981
  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. CURR_GNUSOCIAL_COMMIT=$(get_completion_param "gnusocial commit")
  310. if [[ "$CURR_GNUSOCIAL_COMMIT" == "$GNUSOCIAL_COMMIT" ]]; then
  311. return
  312. fi
  313. if grep -q "gnusocial domain" $COMPLETION_FILE; then
  314. GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
  315. fi
  316. # update to the next commit
  317. function_check set_repo_commit
  318. set_repo_commit /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs "gnusocial commit" "$GNUSOCIAL_COMMIT" $GNUSOCIAL_REPO
  319. gnusocial_fix_endless_reloads
  320. # Ensure that installation script is removed
  321. if [ -f /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/install.php ]; then
  322. rm /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/install.php
  323. fi
  324. if [ -d $INSTALL_DIR/pleroma ]; then
  325. if [ -f /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs/index.php ]; then
  326. mv /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs/index.php /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs/index_qvitter.php
  327. fi
  328. fi
  329. gnusocial_block_user_script
  330. gnusocial_block_domain_script gnusocial $GNUSOCIAL_DOMAIN_NAME
  331. gnusocial_hourly_script gnusocial $GNUSOCIAL_DOMAIN_NAME
  332. if [ -d $INSTALL_DIR/pleroma ]; then
  333. upgrade_pleroma "$GNUSOCIAL_DOMAIN_NAME" "gnusocial" "$GNUSOCIAL_BACKGROUND_IMAGE_URL" "$GNUSOCIAL_TITLE"
  334. fi
  335. install_gnusocial_default_background "gnusocial" "$GNUSOCIAL_DOMAIN_NAME"
  336. chown -R www-data:www-data /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs
  337. }
  338. function backup_local_gnusocial {
  339. GNUSOCIAL_DOMAIN_NAME='gnusocial'
  340. if grep -q "gnusocial domain" $COMPLETION_FILE; then
  341. GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
  342. fi
  343. source_directory=/var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs
  344. if [ -d $source_directory ]; then
  345. dest_directory=gnusocial
  346. function_check suspend_site
  347. suspend_site ${GNUSOCIAL_DOMAIN_NAME}
  348. function_check backup_directory_to_usb
  349. backup_directory_to_usb $source_directory $dest_directory
  350. function_check backup_database_to_usb
  351. backup_database_to_usb gnusocial
  352. function_check restart_site
  353. restart_site
  354. fi
  355. }
  356. function restore_local_gnusocial {
  357. if ! grep -q "gnusocial domain" $COMPLETION_FILE; then
  358. return
  359. fi
  360. GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
  361. if [ $GNUSOCIAL_DOMAIN_NAME ]; then
  362. echo $"Restoring gnusocial"
  363. temp_restore_dir=/root/tempgnusocial
  364. gnusocial_dir=/var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs
  365. # stop the daemons
  366. cd $gnusocial_dir
  367. scripts/stopdaemons.sh
  368. function_check gnusocial_create_database
  369. gnusocial_create_database
  370. restore_database gnusocial ${GNUSOCIAL_DOMAIN_NAME}
  371. if [ -d $temp_restore_dir ]; then
  372. rm -rf $temp_restore_dir
  373. fi
  374. # start the daemons
  375. cd $gnusocial_dir
  376. su -c "sh scripts/startdaemons.sh" -s /bin/sh www-data
  377. echo $"Restore of gnusocial complete"
  378. fi
  379. }
  380. function backup_remote_gnusocial {
  381. if grep -q "gnusocial domain" $COMPLETION_FILE; then
  382. GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
  383. temp_backup_dir=/var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs
  384. if [ -d $temp_backup_dir ]; then
  385. function_check suspend_site
  386. suspend_site ${GNUSOCIAL_DOMAIN_NAME}
  387. function_check backup_database_to_friend
  388. backup_database_to_friend gnusocial
  389. echo $"Backing up GNU social installation"
  390. function_check backup_directory_to_friend
  391. backup_directory_to_friend $temp_backup_dir gnusocial
  392. function_check restart_site
  393. restart_site
  394. else
  395. echo $"gnusocial domain specified but not found in ${temp_backup_dir}"
  396. fi
  397. fi
  398. }
  399. function restore_remote_gnusocial {
  400. if grep -q "gnusocial domain" $COMPLETION_FILE; then
  401. echo $"Restoring gnusocial"
  402. GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
  403. # stop the daemons
  404. cd /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs
  405. scripts/stopdaemons.sh
  406. function_check gnusocial_create_database
  407. gnusocial_create_database
  408. function_check restore_database_from_friend
  409. restore_database_from_friend gnusocial ${GNUSOCIAL_DOMAIN_NAME}
  410. if [ -d /root/tempgnusocial ]; then
  411. rm -rf /root/tempgnusocial
  412. fi
  413. # start the daemons
  414. cd /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs
  415. su -c "sh scripts/startdaemons.sh" -s /bin/sh www-data
  416. echo $"Restore of gnusocial complete"
  417. fi
  418. }
  419. function remove_gnusocial {
  420. if [ ${#GNUSOCIAL_DOMAIN_NAME} -eq 0 ]; then
  421. return
  422. fi
  423. function_check remove_nodejs
  424. remove_nodejs pleroma-gnusocial
  425. read_config_param "GNUSOCIAL_DOMAIN_NAME"
  426. read_config_param "MY_USERNAME"
  427. echo "Removing $GNUSOCIAL_DOMAIN_NAME"
  428. nginx_dissite $GNUSOCIAL_DOMAIN_NAME
  429. remove_certs $GNUSOCIAL_DOMAIN_NAME
  430. if [ -f /etc/cron.hourly/gnusocial-daemons ]; then
  431. rm /etc/cron.hourly/gnusocial-daemons
  432. fi
  433. if [ -f /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/scripts/stopdaemons.sh ]; then
  434. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
  435. scripts/stopdaemons.sh
  436. fi
  437. kill_pid=$(ps aux | grep /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/scripts/queuedaemon.php | awk -F ' ' '{print $2}' | head -n 1)
  438. kill -9 $kill_pid
  439. if [ -d /var/www/$GNUSOCIAL_DOMAIN_NAME ]; then
  440. rm -rf /var/www/$GNUSOCIAL_DOMAIN_NAME
  441. fi
  442. if [ -f /etc/nginx/sites-available/$GNUSOCIAL_DOMAIN_NAME ]; then
  443. rm /etc/nginx/sites-available/$GNUSOCIAL_DOMAIN_NAME
  444. fi
  445. function_check drop_database
  446. drop_database gnusocial
  447. function_check remove_onion_service
  448. remove_onion_service gnusocial ${GNUSOCIAL_ONION_PORT}
  449. if grep -q "gnusocial" /etc/crontab; then
  450. sed -i "/gnusocial/d" /etc/crontab
  451. fi
  452. remove_app gnusocial
  453. remove_completion_param install_gnusocial
  454. sed -i '/gnusocial/d' $COMPLETION_FILE
  455. remove_backup_database_local gnusocial
  456. sed -i '/gnusocial-firewall/d' /etc/crontab
  457. function_check remove_ddns_domain
  458. remove_ddns_domain $GNUSOCIAL_DOMAIN_NAME
  459. }
  460. function install_gnusocial_main {
  461. if [ ! $GNUSOCIAL_DOMAIN_NAME ]; then
  462. echo $'No domain name was given for gnusocial'
  463. exit 7359
  464. fi
  465. if [[ $(app_is_installed gnusocial_main) == "1" ]]; then
  466. return
  467. fi
  468. gnusocial_hourly_script gnusocial $GNUSOCIAL_DOMAIN_NAME
  469. function_check install_mariadb
  470. install_mariadb
  471. function_check get_mariadb_password
  472. get_mariadb_password
  473. function_check repair_databases_script
  474. repair_databases_script
  475. apt-get -yq install php-gettext php-curl php-gd php-mysql git curl
  476. apt-get -yq install memcached php-memcached php-intl exiftool libfcgi0ldbl
  477. if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME ]; then
  478. mkdir /var/www/$GNUSOCIAL_DOMAIN_NAME
  479. fi
  480. if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs ]; then
  481. function_check git_clone
  482. git_clone $GNUSOCIAL_REPO /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
  483. if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs ]; then
  484. echo $'Unable to clone gnusocial repo'
  485. exit 87525
  486. fi
  487. fi
  488. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
  489. git checkout $GNUSOCIAL_COMMIT -b $GNUSOCIAL_COMMIT
  490. set_completion_param "gnusocial commit" "$GNUSOCIAL_COMMIT"
  491. gnusocial_fix_endless_reloads
  492. chmod g+w /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
  493. chmod a+w /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/avatar
  494. chmod a+w /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/file
  495. chown -R www-data:www-data /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
  496. chmod +x /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/scripts/maildaemon.php
  497. function_check gnusocial_create_database
  498. gnusocial_create_database
  499. if [ ! -f "/etc/aliases" ]; then
  500. touch /etc/aliases
  501. fi
  502. if ! grep -q "www-data: root" /etc/aliases; then
  503. echo 'www-data: root' >> /etc/aliases
  504. fi
  505. if ! grep -q "/var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/scripts/maildaemon.php" /etc/aliases; then
  506. echo "*: /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/scripts/maildaemon.php" >> /etc/aliases
  507. fi
  508. function_check add_ddns_domain
  509. add_ddns_domain $GNUSOCIAL_DOMAIN_NAME
  510. gnusocial_nginx_site=/etc/nginx/sites-available/$GNUSOCIAL_DOMAIN_NAME
  511. if [[ $ONION_ONLY == "no" ]]; then
  512. function_check nginx_http_redirect
  513. nginx_http_redirect $GNUSOCIAL_DOMAIN_NAME "index index.php"
  514. echo 'server {' >> $gnusocial_nginx_site
  515. echo ' listen 443 ssl;' >> $gnusocial_nginx_site
  516. echo ' listen [::]:443 ssl;' >> $gnusocial_nginx_site
  517. echo " server_name $GNUSOCIAL_DOMAIN_NAME;" >> $gnusocial_nginx_site
  518. echo '' >> $gnusocial_nginx_site
  519. function_check nginx_compress
  520. nginx_compress $GNUSOCIAL_DOMAIN_NAME
  521. echo '' >> $gnusocial_nginx_site
  522. echo ' # Security' >> $gnusocial_nginx_site
  523. function_check nginx_ssl
  524. nginx_ssl $GNUSOCIAL_DOMAIN_NAME
  525. function_check nginx_disable_sniffing
  526. nginx_disable_sniffing $GNUSOCIAL_DOMAIN_NAME
  527. echo ' add_header Strict-Transport-Security max-age=15768000;' >> $gnusocial_nginx_site
  528. echo '' >> $gnusocial_nginx_site
  529. echo ' # Logs' >> $gnusocial_nginx_site
  530. echo ' access_log /dev/null;' >> $gnusocial_nginx_site
  531. echo ' error_log /dev/null;' >> $gnusocial_nginx_site
  532. echo '' >> $gnusocial_nginx_site
  533. echo ' # Root' >> $gnusocial_nginx_site
  534. echo " root /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs;" >> $gnusocial_nginx_site
  535. echo '' >> $gnusocial_nginx_site
  536. echo ' # Index' >> $gnusocial_nginx_site
  537. echo ' index index.php;' >> $gnusocial_nginx_site
  538. echo '' >> $gnusocial_nginx_site
  539. echo ' # PHP' >> $gnusocial_nginx_site
  540. echo ' location ~ \.php {' >> $gnusocial_nginx_site
  541. echo ' include snippets/fastcgi-php.conf;' >> $gnusocial_nginx_site
  542. echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;' >> $gnusocial_nginx_site
  543. echo ' }' >> $gnusocial_nginx_site
  544. echo '' >> $gnusocial_nginx_site
  545. echo ' # Location' >> $gnusocial_nginx_site
  546. echo ' location / {' >> $gnusocial_nginx_site
  547. function_check nginx_limits
  548. nginx_limits $GNUSOCIAL_DOMAIN_NAME '15m'
  549. echo ' try_files $uri $uri/ @gnusocial;' >> $gnusocial_nginx_site
  550. echo ' }' >> $gnusocial_nginx_site
  551. echo '' >> $gnusocial_nginx_site
  552. echo ' # Fancy URLs' >> $gnusocial_nginx_site
  553. echo ' location @gnusocial {' >> $gnusocial_nginx_site
  554. echo ' rewrite ^(.*)$ /index.php?p=$1 last;' >> $gnusocial_nginx_site
  555. echo ' }' >> $gnusocial_nginx_site
  556. echo '' >> $gnusocial_nginx_site
  557. echo ' # Restrict access that is unnecessary anyway' >> $gnusocial_nginx_site
  558. echo ' location ~ /\.(ht|git) {' >> $gnusocial_nginx_site
  559. echo ' deny all;' >> $gnusocial_nginx_site
  560. echo ' }' >> $gnusocial_nginx_site
  561. echo '' >> $gnusocial_nginx_site
  562. # DO NOT ENABLE KEYBASE. gnusocial really doesn't like having a .well-known directory
  563. echo '}' >> $gnusocial_nginx_site
  564. else
  565. echo -n '' > $gnusocial_nginx_site
  566. fi
  567. echo 'server {' >> $gnusocial_nginx_site
  568. echo " listen 127.0.0.1:$GNUSOCIAL_ONION_PORT default_server;" >> $gnusocial_nginx_site
  569. echo " server_name $GNUSOCIAL_DOMAIN_NAME;" >> $gnusocial_nginx_site
  570. echo '' >> $gnusocial_nginx_site
  571. function_check nginx_compress
  572. nginx_compress $GNUSOCIAL_DOMAIN_NAME
  573. echo '' >> $gnusocial_nginx_site
  574. function_check nginx_disable_sniffing
  575. nginx_disable_sniffing $GNUSOCIAL_DOMAIN_NAME
  576. echo '' >> $gnusocial_nginx_site
  577. echo ' # Logs' >> $gnusocial_nginx_site
  578. echo ' access_log /dev/null;' >> $gnusocial_nginx_site
  579. echo ' error_log /dev/null;' >> $gnusocial_nginx_site
  580. echo '' >> $gnusocial_nginx_site
  581. echo ' # Root' >> $gnusocial_nginx_site
  582. echo " root /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs;" >> $gnusocial_nginx_site
  583. echo '' >> $gnusocial_nginx_site
  584. echo ' # Index' >> $gnusocial_nginx_site
  585. echo ' index index.php;' >> $gnusocial_nginx_site
  586. echo '' >> $gnusocial_nginx_site
  587. echo ' # PHP' >> $gnusocial_nginx_site
  588. echo ' location ~ \.php {' >> $gnusocial_nginx_site
  589. echo ' include snippets/fastcgi-php.conf;' >> $gnusocial_nginx_site
  590. echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;' >> $gnusocial_nginx_site
  591. echo ' }' >> $gnusocial_nginx_site
  592. echo '' >> $gnusocial_nginx_site
  593. echo ' # Location' >> $gnusocial_nginx_site
  594. echo ' location / {' >> $gnusocial_nginx_site
  595. function_check nginx_limits
  596. nginx_limits $GNUSOCIAL_DOMAIN_NAME '15m'
  597. echo ' try_files $uri $uri/ @gnusocial;' >> $gnusocial_nginx_site
  598. echo ' }' >> $gnusocial_nginx_site
  599. echo '' >> $gnusocial_nginx_site
  600. echo ' # Fancy URLs' >> $gnusocial_nginx_site
  601. echo ' location @gnusocial {' >> $gnusocial_nginx_site
  602. echo ' rewrite ^(.*)$ /index.php?p=$1 last;' >> $gnusocial_nginx_site
  603. echo ' }' >> $gnusocial_nginx_site
  604. echo '' >> $gnusocial_nginx_site
  605. echo ' # Restrict access that is unnecessary anyway' >> $gnusocial_nginx_site
  606. echo ' location ~ /\.(ht|git) {' >> $gnusocial_nginx_site
  607. echo ' deny all;' >> $gnusocial_nginx_site
  608. echo ' }' >> $gnusocial_nginx_site
  609. echo '' >> $gnusocial_nginx_site
  610. # DO NOT ENABLE KEYBASE. gnusocial really doesn't like having a .well-known directory
  611. echo '}' >> $gnusocial_nginx_site
  612. function_check configure_php
  613. configure_php
  614. function_check create_site_certificate
  615. create_site_certificate $GNUSOCIAL_DOMAIN_NAME 'yes'
  616. # Ensure that the database gets backed up locally, if remote
  617. # backups are not being used
  618. function_check backup_databases_script_header
  619. backup_databases_script_header
  620. function_check backup_database_local
  621. backup_database_local gnusocial
  622. function_check nginx_ensite
  623. nginx_ensite $GNUSOCIAL_DOMAIN_NAME
  624. # NOTE: For the typical case always enable SSL and only
  625. # disable it if in onion only mode. This is due to complexities
  626. # with the way URLs are generated by gnusocial
  627. gnusocial_ssl='always'
  628. if [[ $ONION_ONLY != 'no' ]]; then
  629. gnusocial_ssl='never'
  630. fi
  631. GNUSOCIAL_ONION_HOSTNAME=$(add_onion_service gnusocial 80 ${GNUSOCIAL_ONION_PORT})
  632. GNUSOCIAL_SERVER=${GNUSOCIAL_DOMAIN_NAME}
  633. if [[ $ONION_ONLY != 'no' ]]; then
  634. GNUSOCIAL_SERVER=${GNUSOCIAL_ONION_HOSTNAME}
  635. fi
  636. # Create the configuration
  637. gnusocial_installer=/var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs/scripts/install_cli.php
  638. if [ ! -f $gnusocial_installer ]; then
  639. rm -rf /var/www/$GNUSOCIAL_DOMAIN_NAME
  640. echo $'No gnusocial commandline installer found'
  641. exit 53026
  642. fi
  643. ${gnusocial_installer} --server "${GNUSOCIAL_SERVER}" \
  644. --host="localhost" --database="gnusocial" \
  645. --dbtype=mysql --username="root" -v \
  646. --password="$MARIADB_PASSWORD" \
  647. --sitename=$"GNU Social" --fancy='yes' \
  648. --admin-nick="$MY_USERNAME" \
  649. --admin-pass="$GNUSOCIAL_ADMIN_PASSWORD" \
  650. --site-profile="community" \
  651. --ssl=${gnusocial_ssl}
  652. # There can be a lot of warnings here so the return value check is disabled
  653. #if [ ! "$?" = "0" ]; then
  654. # # failed to install
  655. # echo $'Could not install GNU Social'
  656. # exit 72357
  657. #fi
  658. # check gnusocial has a config file
  659. gnusocial_config_file=/var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/config.php
  660. if [ ! -f $gnusocial_config_file ]; then
  661. drop_database gnusocial
  662. rm -rf /var/www/$GNUSOCIAL_DOMAIN_NAME
  663. echo $'Gnusocial config.php not found'
  664. exit 87586
  665. fi
  666. # Some useful settings
  667. if ! grep -q "Recommended GNU social settings" $gnusocial_config_file; then
  668. echo "" >> $gnusocial_config_file
  669. echo "// Recommended GNU social settings" >> $gnusocial_config_file
  670. echo "\$config['thumbnail']['maxsize'] = 3000;" >> $gnusocial_config_file
  671. echo "\$config['profile']['delete'] = true;" >> $gnusocial_config_file
  672. echo "\$config['profile']['changenick'] = true;" >> $gnusocial_config_file
  673. echo "\$config['public']['localonly'] = false;" >> $gnusocial_config_file
  674. echo "addPlugin('StoreRemoteMedia');" >> $gnusocial_config_file
  675. echo "\$config['queue']['enabled'] = true;" >> $gnusocial_config_file
  676. echo "\$config['queue']['daemon'] = true;" >> $gnusocial_config_file
  677. echo "\$config['ostatus']['hub_retries'] = 3;" >> $gnusocial_config_file
  678. fi
  679. # turn off logging
  680. echo "\$config['site']['logfile'] = '/dev/null';" >> $gnusocial_config_file
  681. echo "\$config['mail']['domain'] = '${DEFAULT_DOMAIN_NAME}';" >> $gnusocial_config_file
  682. # This improves performance
  683. sed -i "s|//\$config\['db'\]\['schemacheck'\].*|\$config\['db'\]\['schemacheck'\] = 'script';|g" $gnusocial_config_file
  684. systemctl restart mariadb
  685. systemctl restart php7.0-fpm
  686. systemctl restart nginx
  687. ${PROJECT_NAME}-addemail -u $MY_USERNAME -e "noreply@$GNUSOCIAL_DOMAIN_NAME" -g gnusocial --public no
  688. ${PROJECT_NAME}-pass -u $MY_USERNAME -a gnusocial -p "$GNUSOCIAL_ADMIN_PASSWORD"
  689. gnusocial_block_user_script
  690. gnusocial_block_domain_script gnusocial "$GNUSOCIAL_DOMAIN_NAME"
  691. set_completion_param "gnusocial domain" "$GNUSOCIAL_DOMAIN_NAME"
  692. install_completed gnusocial_main
  693. }
  694. function install_gnusocial_plugin_sharings {
  695. if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins ]; then
  696. echo $'No local/plugins directory found for the gnusocial'
  697. exit 72945
  698. fi
  699. apt-get -yq install liblocale-msgfmt-perl gettext
  700. # update to the next commit
  701. function_check set_repo_commit
  702. set_repo_commit /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins "gnusocial sharings plugin commit" "$SHARINGS_COMMIT" $SHARINGS_REPO
  703. if [[ $(app_is_installed gnusocial_plugin_sharings) == "1" ]]; then
  704. return
  705. fi
  706. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins
  707. function_check git_clone
  708. git_clone $SHARINGS_REPO Sharings
  709. if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings ]; then
  710. echo $'Unable to clone gnusocial sharings plugin'
  711. exit 36738
  712. fi
  713. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings
  714. git stash
  715. git checkout master
  716. git branch -D $SHARINGS_COMMIT
  717. git checkout $SHARINGS_COMMIT -b $SHARINGS_COMMIT
  718. # enable the plugin
  719. if ! grep -q "addPlugin('Sharings');" /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/config.php; then
  720. echo "addPlugin('Sharings');" >> /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/config.php
  721. fi
  722. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
  723. php scripts/checkschema.php
  724. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings
  725. php scripts/seedsharings.php
  726. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
  727. php scripts/upgrade.php
  728. php scripts/checkschema.php
  729. # Languages
  730. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings/locale/en/LC_MESSAGES
  731. msgfmt -o Sharings.mo Sharings.po
  732. if [ ! -f Sharings.po ]; then
  733. echo $'English translations for gnusocial sharings plugin were not created'
  734. exit 84352
  735. fi
  736. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings/locale/en_GB/LC_MESSAGES
  737. msgfmt -o Sharings.mo Sharings.po
  738. if [ ! -f Sharings.po ]; then
  739. echo $'English (GB) translations for gnusocial sharings plugin were not created'
  740. exit 84352
  741. fi
  742. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings/locale/en_US/LC_MESSAGES
  743. msgfmt -o Sharings.mo Sharings.po
  744. if [ ! -f Sharings.po ]; then
  745. echo $'English (US) translations for gnusocial sharings plugin were not created'
  746. exit 84352
  747. fi
  748. # Looks like this update function isn't supported by the current php version
  749. sed -i 's|ActivityVerb::UPDATE, ||g' /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings/SharingsPlugin.php
  750. chown -R www-data:www-data /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
  751. set_completion_param gnusocial "sharings plugin commit" "$SHARINGS_COMMIT"
  752. install_completed gnusocial_plugin_sharings
  753. }
  754. function install_gnusocial_plugin_sharings_theme {
  755. if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins ]; then
  756. echo $'No local/plugins directory found for the gnusocial'
  757. exit 74458
  758. fi
  759. # update to the next commit
  760. function_check set_repo_commit
  761. set_repo_commit /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins "gnusocial sharings theme plugin commit" "$SHARINGS_THEME_COMMIT" $SHARINGS_THEME_REPO
  762. if [[ $(app_is_installed gnusocial_plugin_sharings_theme) == "1" ]]; then
  763. return
  764. fi
  765. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins
  766. function_check git_clone
  767. git_clone $SHARINGS_THEME_REPO SharingsTheme
  768. if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/SharingsTheme ]; then
  769. echo $'Unable to clone gnusocial sharings plugin theme'
  770. exit 639253
  771. fi
  772. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/SharingsTheme
  773. git stash
  774. git checkout master
  775. git branch -D $SHARINGS_THEME_COMMIT
  776. git checkout $SHARINGS_THEME_COMMIT -b $SHARINGS_THEME_COMMIT
  777. # enable the plugin
  778. if ! grep -q "addPlugin('SharingsTheme');" /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/config.php; then
  779. echo "addPlugin('SharingsTheme');" >> /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/config.php
  780. fi
  781. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
  782. php scripts/checkschema.php
  783. chown -R www-data:www-data /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
  784. set_completion_param "gnusocial sharings plugin theme commit" "$SHARINGS_THEME_COMMIT"
  785. install_completed gnusocial_plugin_sharings_theme
  786. }
  787. function install_gnusocial_markdown {
  788. GNUSOCIAL_PATH=/var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
  789. # update to the next commit
  790. function_check set_repo_commit
  791. set_repo_commit $GNUSOCIAL_PATH/local/plugins/Markdown "gnusocial Markdown commit" "$GNUSOCIAL_MARKDOWN_COMMIT" $GNUSOCIAL_MARKDOWN_REPO
  792. if [[ $(app_is_installed gnusocial_markdown) == "1" ]]; then
  793. return
  794. fi
  795. if [ -d $GNUSOCIAL_PATH/local/plugins/Markdown ]; then
  796. rm -rf $GNUSOCIAL_PATH/local/plugins/Markdown
  797. fi
  798. if [ ! -d $GNUSOCIAL_PATH/local/plugins ]; then
  799. mkdir -p $GNUSOCIAL_PATH/local/plugins
  800. fi
  801. cd $GNUSOCIAL_PATH/local/plugins
  802. function_check git_clone
  803. git_clone $GNUSOCIAL_MARKDOWN_REPO Markdown
  804. cd $GNUSOCIAL_PATH/local/plugins/Markdown
  805. git checkout $GNUSOCIAL_MARKDOWN_COMMIT -b $GNUSOCIAL_MARKDOWN_COMMIT
  806. gnusocial_config_file=$GNUSOCIAL_PATH/config.php
  807. if ! grep -q "addPlugin('Markdown'" $gnusocial_config_file; then
  808. echo "" >> $gnusocial_config_file
  809. echo "// Markdown settings" >> $gnusocial_config_file
  810. echo "addPlugin('Markdown');" >> $gnusocial_config_file
  811. fi
  812. set_completion_param "gnusocial markdown commit" "$GNUSOCIAL_MARKDOWN_COMMIT"
  813. chown -R www-data:www-data $GNUSOCIAL_PATH
  814. install_completed gnusocial_markdown
  815. }
  816. function install_gnusocial {
  817. if [ ! $ONION_ONLY ]; then
  818. ONION_ONLY='no'
  819. fi
  820. install_gnusocial_main
  821. expire_gnusocial_posts "$GNUSOCIAL_DOMAIN_NAME" "gnusocial" "$GNUSOCIAL_EXPIRE_MONTHS"
  822. install_qvitter "$GNUSOCIAL_DOMAIN_NAME" "gnusocial"
  823. install_gnusocial_markdown
  824. #install_gnusocial_plugin_sharings
  825. #install_gnusocial_plugin_sharings_theme
  826. # Currently Pleroma won't install on ARM systems
  827. # because it uses node-sass which doesn't support ARM
  828. if [[ "$(arch)" == "arm"* ]]; then
  829. echo -m $'WARNING: Pleroma currently does not support ARM '
  830. echo $'architecture, so it will not be installed'
  831. else
  832. function_check install_nodejs
  833. install_nodejs pleroma-gnusocial
  834. install_pleroma_front_end "gnusocial" "$GNUSOCIAL_DOMAIN_NAME" "$GNUSOCIAL_BACKGROUND_IMAGE_URL" "$GNUSOCIAL_TITLE"
  835. install_gnusocial_default_background "gnusocial" "$GNUSOCIAL_DOMAIN_NAME"
  836. sed -i 's|"theme":.*|"theme": "base16-apathy.css",|g' /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs/static/config.json
  837. fi
  838. # unleash the daemons!
  839. /etc/cron.hourly/gnusocial-daemons
  840. systemctl restart nginx
  841. APP_INSTALLED=1
  842. }
  843. # NOTE: deliberately there is no "exit 0"