freedombone-app-gnusocial 37KB

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