freedombone-app-gnusocial 37KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967
  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='985f3b44b7378d95a5294b85beac6c8506810a48'
  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. scripts/stopdaemons.sh
  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. scripts/startdaemons.sh
  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. ./scripts/stopdaemons.sh
  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. ./scripts/startdaemons.sh
  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. ./scripts/stopdaemons.sh
  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 php5-curl php5-gd php5-mysql git curl php-xml-parser
  470. apt-get -yq install php5-memcached php5-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. echo ' # Security' >> $gnusocial_nginx_site
  514. function_check nginx_ssl
  515. nginx_ssl $GNUSOCIAL_DOMAIN_NAME
  516. function_check nginx_disable_sniffing
  517. nginx_disable_sniffing $GNUSOCIAL_DOMAIN_NAME
  518. echo ' add_header Strict-Transport-Security max-age=15768000;' >> $gnusocial_nginx_site
  519. echo '' >> $gnusocial_nginx_site
  520. echo ' # Logs' >> $gnusocial_nginx_site
  521. echo ' access_log /dev/null;' >> $gnusocial_nginx_site
  522. echo ' error_log /dev/null;' >> $gnusocial_nginx_site
  523. echo '' >> $gnusocial_nginx_site
  524. echo ' # Root' >> $gnusocial_nginx_site
  525. echo " root /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs;" >> $gnusocial_nginx_site
  526. echo '' >> $gnusocial_nginx_site
  527. echo ' # Index' >> $gnusocial_nginx_site
  528. echo ' index index.php;' >> $gnusocial_nginx_site
  529. echo '' >> $gnusocial_nginx_site
  530. echo ' # PHP' >> $gnusocial_nginx_site
  531. echo ' location ~ \.php {' >> $gnusocial_nginx_site
  532. echo ' include snippets/fastcgi-php.conf;' >> $gnusocial_nginx_site
  533. echo ' fastcgi_pass unix:/var/run/php5-fpm.sock;' >> $gnusocial_nginx_site
  534. echo ' }' >> $gnusocial_nginx_site
  535. echo '' >> $gnusocial_nginx_site
  536. echo ' # Location' >> $gnusocial_nginx_site
  537. echo ' location / {' >> $gnusocial_nginx_site
  538. function_check nginx_limits
  539. nginx_limits $GNUSOCIAL_DOMAIN_NAME '15m'
  540. echo ' try_files $uri $uri/ @gnusocial;' >> $gnusocial_nginx_site
  541. echo ' }' >> $gnusocial_nginx_site
  542. echo '' >> $gnusocial_nginx_site
  543. echo ' # Fancy URLs' >> $gnusocial_nginx_site
  544. echo ' location @gnusocial {' >> $gnusocial_nginx_site
  545. echo ' rewrite ^(.*)$ /index.php?p=$1 last;' >> $gnusocial_nginx_site
  546. echo ' }' >> $gnusocial_nginx_site
  547. echo '' >> $gnusocial_nginx_site
  548. echo ' # Restrict access that is unnecessary anyway' >> $gnusocial_nginx_site
  549. echo ' location ~ /\.(ht|git) {' >> $gnusocial_nginx_site
  550. echo ' deny all;' >> $gnusocial_nginx_site
  551. echo ' }' >> $gnusocial_nginx_site
  552. echo '' >> $gnusocial_nginx_site
  553. # DO NOT ENABLE KEYBASE. gnusocial really doesn't like having a .well-known directory
  554. echo '}' >> $gnusocial_nginx_site
  555. else
  556. echo -n '' > $gnusocial_nginx_site
  557. fi
  558. echo 'server {' >> $gnusocial_nginx_site
  559. echo " listen 127.0.0.1:$GNUSOCIAL_ONION_PORT default_server;" >> $gnusocial_nginx_site
  560. echo " server_name $GNUSOCIAL_DOMAIN_NAME;" >> $gnusocial_nginx_site
  561. echo '' >> $gnusocial_nginx_site
  562. function_check nginx_disable_sniffing
  563. nginx_disable_sniffing $GNUSOCIAL_DOMAIN_NAME
  564. echo '' >> $gnusocial_nginx_site
  565. echo ' # Logs' >> $gnusocial_nginx_site
  566. echo ' access_log /dev/null;' >> $gnusocial_nginx_site
  567. echo ' error_log /dev/null;' >> $gnusocial_nginx_site
  568. echo '' >> $gnusocial_nginx_site
  569. echo ' # Root' >> $gnusocial_nginx_site
  570. echo " root /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs;" >> $gnusocial_nginx_site
  571. echo '' >> $gnusocial_nginx_site
  572. echo ' # Index' >> $gnusocial_nginx_site
  573. echo ' index index.php;' >> $gnusocial_nginx_site
  574. echo '' >> $gnusocial_nginx_site
  575. echo ' # PHP' >> $gnusocial_nginx_site
  576. echo ' location ~ \.php {' >> $gnusocial_nginx_site
  577. echo ' include snippets/fastcgi-php.conf;' >> $gnusocial_nginx_site
  578. echo ' fastcgi_pass unix:/var/run/php5-fpm.sock;' >> $gnusocial_nginx_site
  579. echo ' }' >> $gnusocial_nginx_site
  580. echo '' >> $gnusocial_nginx_site
  581. echo ' # Location' >> $gnusocial_nginx_site
  582. echo ' location / {' >> $gnusocial_nginx_site
  583. function_check nginx_limits
  584. nginx_limits $GNUSOCIAL_DOMAIN_NAME '15m'
  585. echo ' try_files $uri $uri/ @gnusocial;' >> $gnusocial_nginx_site
  586. echo ' }' >> $gnusocial_nginx_site
  587. echo '' >> $gnusocial_nginx_site
  588. echo ' # Fancy URLs' >> $gnusocial_nginx_site
  589. echo ' location @gnusocial {' >> $gnusocial_nginx_site
  590. echo ' rewrite ^(.*)$ /index.php?p=$1 last;' >> $gnusocial_nginx_site
  591. echo ' }' >> $gnusocial_nginx_site
  592. echo '' >> $gnusocial_nginx_site
  593. echo ' # Restrict access that is unnecessary anyway' >> $gnusocial_nginx_site
  594. echo ' location ~ /\.(ht|git) {' >> $gnusocial_nginx_site
  595. echo ' deny all;' >> $gnusocial_nginx_site
  596. echo ' }' >> $gnusocial_nginx_site
  597. echo '' >> $gnusocial_nginx_site
  598. # DO NOT ENABLE KEYBASE. gnusocial really doesn't like having a .well-known directory
  599. echo '}' >> $gnusocial_nginx_site
  600. function_check configure_php
  601. configure_php
  602. function_check create_site_certificate
  603. create_site_certificate $GNUSOCIAL_DOMAIN_NAME 'yes'
  604. # Ensure that the database gets backed up locally, if remote
  605. # backups are not being used
  606. function_check backup_databases_script_header
  607. backup_databases_script_header
  608. function_check backup_database_local
  609. backup_database_local gnusocial
  610. function_check nginx_ensite
  611. nginx_ensite $GNUSOCIAL_DOMAIN_NAME
  612. # NOTE: For the typical case always enable SSL and only
  613. # disable it if in onion only mode. This is due to complexities
  614. # with the way URLs are generated by gnusocial
  615. gnusocial_ssl='always'
  616. if [[ $ONION_ONLY != 'no' ]]; then
  617. gnusocial_ssl='never'
  618. fi
  619. GNUSOCIAL_ONION_HOSTNAME=$(add_onion_service gnusocial 80 ${GNUSOCIAL_ONION_PORT})
  620. GNUSOCIAL_SERVER=${GNUSOCIAL_DOMAIN_NAME}
  621. if [[ $ONION_ONLY != 'no' ]]; then
  622. GNUSOCIAL_SERVER=${GNUSOCIAL_ONION_HOSTNAME}
  623. fi
  624. # Create the configuration
  625. gnusocial_installer=/var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs/scripts/install_cli.php
  626. if [ ! -f $gnusocial_installer ]; then
  627. rm -rf /var/www/$GNUSOCIAL_DOMAIN_NAME
  628. echo $'No gnusocial commandline installer found'
  629. exit 53026
  630. fi
  631. ${gnusocial_installer} --server "${GNUSOCIAL_SERVER}" \
  632. --host="localhost" --database="gnusocial" \
  633. --dbtype=mysql --username="root" -v \
  634. --password="$MARIADB_PASSWORD" \
  635. --sitename=$"GNU Social" --fancy='yes' \
  636. --admin-nick="$MY_USERNAME" \
  637. --admin-pass="$GNUSOCIAL_ADMIN_PASSWORD" \
  638. --site-profile="community" \
  639. --ssl=${gnusocial_ssl}
  640. # There can be a lot of warnings here so the return value check is disabled
  641. #if [ ! "$?" = "0" ]; then
  642. # # failed to install
  643. # echo $'Could not install GNU Social'
  644. # exit 72357
  645. #fi
  646. # check gnusocial has a config file
  647. gnusocial_config_file=/var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/config.php
  648. if [ ! -f $gnusocial_config_file ]; then
  649. drop_database gnusocial
  650. rm -rf /var/www/$GNUSOCIAL_DOMAIN_NAME
  651. echo $'Gnusocial config.php not found'
  652. exit 87586
  653. fi
  654. # Some useful settings
  655. if ! grep -q "Recommended GNU social settings" $gnusocial_config_file; then
  656. echo "" >> $gnusocial_config_file
  657. echo "// Recommended GNU social settings" >> $gnusocial_config_file
  658. echo "\$config['thumbnail']['maxsize'] = 3000;" >> $gnusocial_config_file
  659. echo "\$config['profile']['delete'] = true;" >> $gnusocial_config_file
  660. echo "\$config['profile']['changenick'] = true;" >> $gnusocial_config_file
  661. echo "\$config['public']['localonly'] = false;" >> $gnusocial_config_file
  662. echo "addPlugin('StoreRemoteMedia');" >> $gnusocial_config_file
  663. echo "\$config['queue']['enabled'] = true;" >> $gnusocial_config_file
  664. echo "\$config['queue']['daemon'] = true;" >> $gnusocial_config_file
  665. echo "\$config['ostatus']['hub_retries'] = 3;" >> $gnusocial_config_file
  666. fi
  667. # turn off logging
  668. echo "\$config['site']['logfile'] = '/dev/null';" >> $gnusocial_config_file
  669. echo "\$config['mail']['domain'] = '${DEFAULT_DOMAIN_NAME}';" >> $gnusocial_config_file
  670. # This improves performance
  671. sed -i "s|//\$config\['db'\]\['schemacheck'\].*|\$config\['db'\]\['schemacheck'\] = 'script';|g" $gnusocial_config_file
  672. systemctl restart php5-fpm
  673. systemctl restart nginx
  674. ${PROJECT_NAME}-addemail -u $MY_USERNAME -e "noreply@$GNUSOCIAL_DOMAIN_NAME" -g gnusocial --public no
  675. ${PROJECT_NAME}-pass -u $MY_USERNAME -a gnusocial -p "$GNUSOCIAL_ADMIN_PASSWORD"
  676. gnusocial_block_user_script
  677. gnusocial_block_domain_script gnusocial "$GNUSOCIAL_DOMAIN_NAME"
  678. set_completion_param "gnusocial domain" "$GNUSOCIAL_DOMAIN_NAME"
  679. install_completed gnusocial_main
  680. }
  681. function install_gnusocial_plugin_sharings {
  682. if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins ]; then
  683. echo $'No local/plugins directory found for the gnusocial'
  684. exit 72945
  685. fi
  686. apt-get -yq install liblocale-msgfmt-perl gettext
  687. # update to the next commit
  688. function_check set_repo_commit
  689. set_repo_commit /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins "gnusocial sharings plugin commit" "$SHARINGS_COMMIT" $SHARINGS_REPO
  690. if [[ $(app_is_installed gnusocial_plugin_sharings) == "1" ]]; then
  691. return
  692. fi
  693. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins
  694. function_check git_clone
  695. git_clone $SHARINGS_REPO Sharings
  696. if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings ]; then
  697. echo $'Unable to clone gnusocial sharings plugin'
  698. exit 36738
  699. fi
  700. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings
  701. git stash
  702. git checkout master
  703. git branch -D $SHARINGS_COMMIT
  704. git checkout $SHARINGS_COMMIT -b $SHARINGS_COMMIT
  705. # enable the plugin
  706. if ! grep -q "addPlugin('Sharings');" /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/config.php; then
  707. echo "addPlugin('Sharings');" >> /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/config.php
  708. fi
  709. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
  710. php scripts/checkschema.php
  711. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings
  712. php scripts/seedsharings.php
  713. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
  714. php scripts/upgrade.php
  715. php scripts/checkschema.php
  716. # Languages
  717. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings/locale/en/LC_MESSAGES
  718. msgfmt -o Sharings.mo Sharings.po
  719. if [ ! -f Sharings.po ]; then
  720. echo $'English translations for gnusocial sharings plugin were not created'
  721. exit 84352
  722. fi
  723. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings/locale/en_GB/LC_MESSAGES
  724. msgfmt -o Sharings.mo Sharings.po
  725. if [ ! -f Sharings.po ]; then
  726. echo $'English (GB) 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_US/LC_MESSAGES
  730. msgfmt -o Sharings.mo Sharings.po
  731. if [ ! -f Sharings.po ]; then
  732. echo $'English (US) translations for gnusocial sharings plugin were not created'
  733. exit 84352
  734. fi
  735. # Looks like this update function isn't supported by the current php version
  736. sed -i 's|ActivityVerb::UPDATE, ||g' /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings/SharingsPlugin.php
  737. chown -R www-data:www-data /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
  738. set_completion_param gnusocial "sharings plugin commit" "$SHARINGS_COMMIT"
  739. install_completed gnusocial_plugin_sharings
  740. }
  741. function install_gnusocial_plugin_sharings_theme {
  742. if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins ]; then
  743. echo $'No local/plugins directory found for the gnusocial'
  744. exit 74458
  745. fi
  746. # update to the next commit
  747. function_check set_repo_commit
  748. set_repo_commit /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins "gnusocial sharings theme plugin commit" "$SHARINGS_THEME_COMMIT" $SHARINGS_THEME_REPO
  749. if [[ $(app_is_installed gnusocial_plugin_sharings_theme) == "1" ]]; then
  750. return
  751. fi
  752. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins
  753. function_check git_clone
  754. git_clone $SHARINGS_THEME_REPO SharingsTheme
  755. if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/SharingsTheme ]; then
  756. echo $'Unable to clone gnusocial sharings plugin theme'
  757. exit 639253
  758. fi
  759. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/SharingsTheme
  760. git stash
  761. git checkout master
  762. git branch -D $SHARINGS_THEME_COMMIT
  763. git checkout $SHARINGS_THEME_COMMIT -b $SHARINGS_THEME_COMMIT
  764. # enable the plugin
  765. if ! grep -q "addPlugin('SharingsTheme');" /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/config.php; then
  766. echo "addPlugin('SharingsTheme');" >> /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/config.php
  767. fi
  768. cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
  769. php scripts/checkschema.php
  770. chown -R www-data:www-data /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
  771. set_completion_param "gnusocial sharings plugin theme commit" "$SHARINGS_THEME_COMMIT"
  772. install_completed gnusocial_plugin_sharings_theme
  773. }
  774. function install_gnusocial_markdown {
  775. GNUSOCIAL_PATH=/var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
  776. # update to the next commit
  777. function_check set_repo_commit
  778. set_repo_commit $GNUSOCIAL_PATH/local/plugins/Markdown "gnusocial Markdown commit" "$GNUSOCIAL_MARKDOWN_COMMIT" $GNUSOCIAL_MARKDOWN_REPO
  779. if [[ $(app_is_installed gnusocial_markdown) == "1" ]]; then
  780. return
  781. fi
  782. if [ -d $GNUSOCIAL_PATH/local/plugins/Markdown ]; then
  783. rm -rf $GNUSOCIAL_PATH/local/plugins/Markdown
  784. fi
  785. if [ ! -d $GNUSOCIAL_PATH/local/plugins ]; then
  786. mkdir -p $GNUSOCIAL_PATH/local/plugins
  787. fi
  788. cd $GNUSOCIAL_PATH/local/plugins
  789. function_check git_clone
  790. git_clone $GNUSOCIAL_MARKDOWN_REPO Markdown
  791. cd $GNUSOCIAL_PATH/local/plugins/Markdown
  792. git checkout $GNUSOCIAL_MARKDOWN_COMMIT -b $GNUSOCIAL_MARKDOWN_COMMIT
  793. gnusocial_config_file=$GNUSOCIAL_PATH/config.php
  794. if ! grep -q "addPlugin('Markdown'" $gnusocial_config_file; then
  795. echo "" >> $gnusocial_config_file
  796. echo "// Markdown settings" >> $gnusocial_config_file
  797. echo "addPlugin('Markdown');" >> $gnusocial_config_file
  798. fi
  799. set_completion_param "gnusocial markdown commit" "$GNUSOCIAL_MARKDOWN_COMMIT"
  800. chown -R www-data:www-data $GNUSOCIAL_PATH
  801. install_completed gnusocial_markdown
  802. }
  803. function install_gnusocial {
  804. if [ ! $ONION_ONLY ]; then
  805. ONION_ONLY='no'
  806. fi
  807. install_gnusocial_main
  808. expire_gnusocial_posts "$GNUSOCIAL_DOMAIN_NAME" "gnusocial" "$GNUSOCIAL_EXPIRE_MONTHS"
  809. install_qvitter "$GNUSOCIAL_DOMAIN_NAME" "gnusocial"
  810. install_gnusocial_markdown
  811. #install_gnusocial_plugin_sharings
  812. #install_gnusocial_plugin_sharings_theme
  813. # Currently Pleroma won't install on ARM systems
  814. # because it uses node-sass which doesn't support ARM
  815. if [[ "$(arch)" == "arm"* ]]; then
  816. echo -m $'WARNING: Pleroma currently does not support ARM '
  817. echo $'architecture, so it will not be installed'
  818. else
  819. function_check install_nodejs
  820. install_nodejs pleroma-gnusocial
  821. install_pleroma_front_end "gnusocial" "$GNUSOCIAL_DOMAIN_NAME" "$GNUSOCIAL_BACKGROUND_IMAGE_URL" "$GNUSOCIAL_TITLE"
  822. install_gnusocial_default_background "gnusocial" "$GNUSOCIAL_DOMAIN_NAME"
  823. sed -i 's|"theme":.*|"theme": "base16-apathy.css",|g' /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs/static/config.json
  824. fi
  825. # unleash the daemons!
  826. /etc/cron.hourly/gnusocial-daemons
  827. systemctl restart nginx
  828. APP_INSTALLED=1
  829. }
  830. # NOTE: deliberately there is no "exit 0"