freedombone-app-hubzilla 35KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  1. #!/bin/bash
  2. #
  3. # .---. . .
  4. # | | |
  5. # |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
  6. # | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
  7. # ' ' --' --' -' - -' ' ' -' -' -' ' - --'
  8. #
  9. # Freedom in the Cloud
  10. #
  11. # Hubzilla application
  12. #
  13. # License
  14. # =======
  15. #
  16. # Copyright (C) 2014-2016 Bob Mottram <bob@robotics.uk.to>
  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 social'
  31. HUBZILLA_DOMAIN_NAME=
  32. HUBZILLA_CODE=
  33. HUBZILLA_ONION_PORT=8085
  34. HUBZILLA_REPO="https://github.com/redmatrix/hubzilla.git"
  35. HUBZILLA_THEMES_REPO="https://github.com/DeadSuperHero/redmatrix-themes"
  36. HUBZILLA_ADDONS_REPO="https://github.com/redmatrix/hubzilla-addons.git"
  37. HUBZILLA_ADMIN_PASSWORD=
  38. HUBZILLA_COMMIT='8aee932525d0bc341713fe7052e2a5ab318a69c0'
  39. HUBZILLA_ADDONS_COMMIT='4456f097e3faf2adeab696ad08e3f213e82199bd'
  40. function hubzilla_renew_cert {
  41. dialog --title $"Renew SSL certificate" \
  42. --backtitle $"Freedombone Control Panel" \
  43. --yesno $"\nThis will renew a letsencrypt certificate. Select 'yes' to continue" 16 60
  44. sel=$?
  45. case $sel in
  46. 1) return;;
  47. 255) return;;
  48. esac
  49. HUBZILLA_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Hubzilla domain" | awk -F ':' '{print $2}')
  50. if [ ! -d /var/www/$HUBZILLA_DOMAIN_NAME/htdocs ]; then
  51. dialog --title $"Renew SSL certificate" \
  52. --msgbox $"Hubzilla install directory not found" 6 40
  53. return
  54. fi
  55. ${PROJECT_NAME}-renew-cert -h $HUBZILLA_DOMAIN_NAME -p 'letsencrypt'
  56. if [ ! "$?" = "0" ]; then
  57. any_key
  58. else
  59. dialog --title $"Renew SSL certificate" \
  60. --msgbox $"Hubzilla certificate has been renewed" 6 40
  61. fi
  62. }
  63. function hubzilla_channel_directory_server {
  64. if ! grep -q "Hubzilla domain" $COMPLETION_FILE; then
  65. dialog --title $"Hubzilla channel directory server" \
  66. --msgbox $"Hubzilla is not installed on this system" 6 40
  67. return
  68. fi
  69. HUBZILLA_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Hubzilla domain" | awk -F ':' '{print $2}')
  70. if [ ! -d /var/www/$HUBZILLA_DOMAIN_NAME/htdocs ]; then
  71. dialog --title $"Hubzilla channel directory server" \
  72. --msgbox $"Hubzilla install directory not found" 6 40
  73. return
  74. fi
  75. data=$(tempfile 2>/dev/null)
  76. trap "rm -f $data" 0 1 2 5 15
  77. dialog --title $"Hubzilla channel directory server" \
  78. --backtitle $"Freedombone Control Panel" \
  79. --inputbox $"When you click on 'channel directory' this is where Hubzilla will obtain its list from" 8 60 2>$data
  80. sel=$?
  81. case $sel in
  82. 0)
  83. hubzilla_domain_server=$(<$data)
  84. if [[ $hubzilla_domain_server != *"."* ]]; then
  85. return
  86. fi
  87. if [[ $hubzilla_domain_server != "https"* ]]; then
  88. dialog --title $"Hubzilla channel directory server" \
  89. --msgbox $"Invalid domain - include the https://" 6 40
  90. return
  91. fi
  92. ./var/www/$HUBZILLA_DOMAIN_NAME/htdocs/util/config system directory_server $hubzilla_domain_server
  93. dialog --title $"Hubzilla channel directory server" \
  94. --msgbox $"Domain channel directory server changed to $hubzilla_domain_server" 6 40
  95. ;;
  96. esac
  97. }
  98. function configure_interactive_hubzilla {
  99. while true
  100. do
  101. data=$(tempfile 2>/dev/null)
  102. trap "rm -f $data" 0 1 2 5 15
  103. dialog --backtitle $"Freedombone Control Panel" \
  104. --title $"Hubzilla" \
  105. --radiolist $"Choose an operation:" 13 70 4 \
  106. 1 $"Set channel directory server" off \
  107. 2 $"Renew SSL certificate" off \
  108. 3 $"Back to main menu" on 2> $data
  109. sel=$?
  110. case $sel in
  111. 1) break;;
  112. 255) break;;
  113. esac
  114. case $(cat $data) in
  115. 1) hubzilla_channel_directory_server;;
  116. 2) hubzilla_renew_cert;;
  117. 3) break;;
  118. esac
  119. done
  120. }
  121. function install_interactive_hubzilla {
  122. if [ ! $ONION_ONLY ]; then
  123. ONION_ONLY='no'
  124. fi
  125. if grep -q "ONION_ONLY" $CONFIGURATION_FILE; then
  126. ONION_ONLY=$(grep "ONION_ONLY" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
  127. fi
  128. if grep -q "HUBZILLA_DOMAIN_NAME" $CONFIGURATION_FILE; then
  129. HUBZILLA_DOMAIN_NAME=$(grep "HUBZILLA_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
  130. fi
  131. if grep -q "HUBZILLA_CODE" $CONFIGURATION_FILE; then
  132. HUBZILLA_CODE=$(grep "HUBZILLA_CODE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
  133. fi
  134. if grep -q "DDNS_PROVIDER" $CONFIGURATION_FILE; then
  135. DDNS_PROVIDER=$(grep "DDNS_PROVIDER" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
  136. fi
  137. if [[ $ONION_ONLY != "no" ]]; then
  138. HUBZILLA_DOMAIN_NAME='hubzilla.local'
  139. else
  140. HUBZILLA_DETAILS_COMPLETE=
  141. while [ ! $HUBZILLA_DETAILS_COMPLETE ]
  142. do
  143. data=$(tempfile 2>/dev/null)
  144. trap "rm -f $data" 0 1 2 5 15
  145. if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
  146. dialog --backtitle $"Freedombone Configuration" \
  147. --title $"Hubzilla Configuration" \
  148. --form $"\nPlease enter your Hubzilla details.\n\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 14 55 3 \
  149. $"Domain:" 1 1 "$(grep 'HUBZILLA_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 16 33 40 \
  150. $"Code:" 2 1 "$(grep 'HUBZILLA_CODE' temp.cfg | awk -F '=' '{print $2}')" 2 16 33 255 \
  151. 2> $data
  152. else
  153. dialog --backtitle $"Freedombone Configuration" \
  154. --title $"Hubzilla Configuration" \
  155. --form $"\nPlease enter your Hubzilla details\n\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 11 55 3 \
  156. $"Domain:" 1 1 "$(grep 'HUBZILLA_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 16 33 40 \
  157. 2> $data
  158. fi
  159. sel=$?
  160. case $sel in
  161. 1) exit 1;;
  162. 255) exit 1;;
  163. esac
  164. HUBZILLA_DOMAIN_NAME=$(cat $data | sed -n 1p)
  165. if [ $HUBZILLA_DOMAIN_NAME ]; then
  166. TEST_DOMAIN_NAME=$HUBZILLA_DOMAIN_NAME
  167. validate_domain_name
  168. if [[ $TEST_DOMAIN_NAME != $HUBZILLA_DOMAIN_NAME ]]; then
  169. HUBZILLA_DOMAIN_NAME=
  170. dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
  171. else
  172. if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
  173. HUBZILLA_CODE=$(cat $data | sed -n 2p)
  174. validate_freedns_code "$HUBZILLA_CODE"
  175. if [ ! $VALID_CODE ]; then
  176. HUBZILLA_DOMAIN_NAME=
  177. fi
  178. fi
  179. fi
  180. fi
  181. if [ $HUBZILLA_DOMAIN_NAME ]; then
  182. HUBZILLA_DETAILS_COMPLETE="yes"
  183. fi
  184. done
  185. # save the results in the config file
  186. if grep -q "HUBZILLA_DOMAIN_NAME=" $CONFIGURATION_FILE; then
  187. sed -i "s|HUBZILLA_DOMAIN_NAME=.*|HUBZILLA_DOMAIN_NAME=$HUBZILLA_DOMAIN_NAME|g" $CONFIGURATION_FILE
  188. else
  189. echo "HUBZILLA_DOMAIN_NAME=$HUBZILLA_DOMAIN_NAME" >> $CONFIGURATION_FILE
  190. fi
  191. if grep -q "HUBZILLA_CODE=" $CONFIGURATION_FILE; then
  192. sed -i "s|HUBZILLA_CODE=.*|HUBZILLA_CODE=$HUBZILLA_CODE|g" $CONFIGURATION_FILE
  193. else
  194. echo "HUBZILLA_CODE=$HUBZILLA_CODE" >> $CONFIGURATION_FILE
  195. fi
  196. fi
  197. }
  198. function change_password_hubzilla {
  199. echo -n ''
  200. }
  201. function get_mariadb_hubzilla_admin_password {
  202. if [ -f /home/$MY_USERNAME/README ]; then
  203. if grep -q "MariaDB Hubzilla admin password" /home/$MY_USERNAME/README; then
  204. HUBZILLA_ADMIN_PASSWORD=$(cat /home/$MY_USERNAME/README | grep "MariaDB Hubzilla admin password" | awk -F ':' '{print $2}' | sed 's/^ *//')
  205. fi
  206. fi
  207. }
  208. function hubzilla_create_database {
  209. function_check get_mariadb_hubzilla_admin_password
  210. get_mariadb_hubzilla_admin_password
  211. if [ ! $HUBZILLA_ADMIN_PASSWORD ]; then
  212. if [ -f $IMAGE_PASSWORD_FILE ]; then
  213. HUBZILLA_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
  214. else
  215. HUBZILLA_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
  216. fi
  217. echo '' >> /home/$MY_USERNAME/README
  218. echo '' >> /home/$MY_USERNAME/README
  219. echo 'Hubzilla' >> /home/$MY_USERNAME/README
  220. echo '========' >> /home/$MY_USERNAME/README
  221. if [[ $ONION_ONLY == 'no' ]]; then
  222. echo $"Open https://$HUBZILLA_DOMAIN_NAME and register a new user" >> /home/$MY_USERNAME/README
  223. else
  224. echo $"Open http://$HUBZILLA_ONION_HOSTNAME and register a new user" >> /home/$MY_USERNAME/README
  225. fi
  226. echo $"Your MariaDB Hubzilla admin password is: $HUBZILLA_ADMIN_PASSWORD" >> /home/$MY_USERNAME/README
  227. chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
  228. chmod 600 /home/$MY_USERNAME/README
  229. fi
  230. if [ ! $HUBZILLA_ADMIN_PASSWORD ]; then
  231. return
  232. fi
  233. function_check create_database
  234. create_database hubzilla "$HUBZILLA_ADMIN_PASSWORD"
  235. }
  236. function reconfigure_hubzilla {
  237. echo -n ''
  238. }
  239. function upgrade_hubzilla {
  240. if ! grep -Fxq "install_hubzilla" $COMPLETION_FILE; then
  241. return
  242. fi
  243. HUBZILLA_PATH=/var/www/$HUBZILLA_DOMAIN_NAME/htdocs
  244. function_check set_repo_commit
  245. set_repo_commit $HUBZILLA_PATH "Hubzilla commit" "$HUBZILLA_COMMIT" $HUBZILLA_REPO
  246. set_repo_commit $HUBZILLA_PATH/addon "Hubzilla addons commit" "$HUBZILLA_ADDONS_COMMIT" $HUBZILLA_ADDONS_REPO
  247. if [ -d $HUBZILLA_PATH/redmatrix-themes1 ]; then
  248. cd $HUBZILLA_PATH/redmatrix-themes1
  249. git stash
  250. git pull
  251. cp -r $HUBZILLA_PATH/redmatrix-themes1/* $HUBZILLA_PATH/view/theme/
  252. chown -R www-data:www-data $HUBZILLA_PATH
  253. fi
  254. }
  255. function backup_local_hubzilla {
  256. if grep -q "Hubzilla domain" $COMPLETION_FILE; then
  257. HUBZILLA_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Hubzilla domain" | awk -F ':' '{print $2}')
  258. hubzilla_path=/var/www/${HUBZILLA_DOMAIN_NAME}/htdocs
  259. if [ -d $hubzilla_path ]; then
  260. echo $"Backing up Hubzilla"
  261. function_check backup_database_to_usb
  262. backup_database_to_usb hubzilla
  263. backup_directory_to_usb $hubzilla_path hubzilla
  264. echo $"Hubzilla backup complete"
  265. fi
  266. fi
  267. }
  268. function restore_local_hubzilla {
  269. if ! grep -q "Hubzilla domain" $COMPLETION_FILE; then
  270. return
  271. fi
  272. HUBZILLA_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Hubzilla domain" | awk -F ':' '{print $2}')
  273. if [ $HUBZILLA_DOMAIN_NAME ]; then
  274. echo $"Restoring Hubzilla"
  275. temp_restore_dir=/root/temphubzilla
  276. hubzilla_dir=/var/www/${HUBZILLA_DOMAIN_NAME}/htdocs
  277. function_check hubzilla_create_database
  278. hubzilla_create_database
  279. restore_database hubzilla ${HUBZILLA_DOMAIN_NAME}
  280. if [ -d $USB_MOUNT/backup/hubzilla ]; then
  281. if [ ! -d $hubzilla_dir/store/[data]/smarty3 ]; then
  282. mkdir -p $hubzilla_dir/store/[data]/smarty3
  283. fi
  284. chmod 777 $hubzilla_dir/store/[data]/smarty3
  285. chown -R www-data:www-data $hubzilla_dir/*
  286. if [ -d $temp_restore_dir ]; then
  287. rm -rf $temp_restore_dir
  288. fi
  289. fi
  290. echo $"Restore of Hubzilla complete"
  291. fi
  292. }
  293. function backup_remote_hubzilla {
  294. if grep -q "Hubzilla domain" $COMPLETION_FILE; then
  295. HUBZILLA_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Hubzilla domain" | awk -F ':' '{print $2}')
  296. temp_backup_dir=/var/www/${HUBZILLA_DOMAIN_NAME}/htdocs
  297. if [ -d $temp_backup_dir ]; then
  298. suspend_site ${HUBZILLA_DOMAIN_NAME}
  299. backup_database_to_friend hubzilla
  300. echo "Backing up Hubzilla installation"
  301. backup_directory_to_friend $temp_backup_dir hubzilla
  302. restart_site
  303. echo "Backup of Hubzilla complete"
  304. else
  305. echo $"Hubzilla domain specified but not found in /var/www/${HUBZILLA_DOMAIN_NAME}"
  306. exit 2578
  307. fi
  308. fi
  309. }
  310. function restore_remote_hubzilla {
  311. if grep -q "Hubzilla domain" $COMPLETION_FILE; then
  312. echo $"Restoring Hubzilla"
  313. HUBZILLA_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Hubzilla domain" | awk -F ':' '{print $2}')
  314. function_check restore_database_from_friend
  315. function_check hubzilla_create_database
  316. hubzilla_create_database
  317. restore_database_from_friend hubzilla ${HUBZILLA_DOMAIN_NAME}
  318. if [ -d $SERVER_DIRECTORY/backup/hubzilla ]; then
  319. if [ ! -d /var/www/${HUBZILLA_DOMAIN_NAME}/htdocs/store/[data]/smarty3 ]; then
  320. mkdir -p /var/www/${HUBZILLA_DOMAIN_NAME}/htdocs/store/[data]/smarty3
  321. fi
  322. chmod 777 /var/www/${HUBZILLA_DOMAIN_NAME}/htdocs/store/[data]/smarty3
  323. chown -R www-data:www-data /var/www/${HUBZILLA_DOMAIN_NAME}/htdocs/*
  324. fi
  325. if [ -d /root/temphubzilla ]; then
  326. rm -rf /root/temphubzilla
  327. fi
  328. echo $"Restore of Hubzilla complete"
  329. fi
  330. }
  331. function remove_hubzilla {
  332. if [[ $(app_is_installed hubzilla) == "0" ]]; then
  333. return
  334. fi
  335. echo $'Removing Hubzilla'
  336. HUBZILLA_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Hubzilla domain" | awk -F ':' '{print $2}')
  337. nginx_dissite $HUBZILLA_DOMAIN_NAME
  338. if [ -d /var/www/$HUBZILLA_DOMAIN_NAME ]; then
  339. rm -rf /var/www/$HUBZILLA_DOMAIN_NAME
  340. fi
  341. if [ -f /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME ]; then
  342. rm /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  343. fi
  344. function_check drop_database
  345. drop_database hubzilla
  346. function_check remove_onion_service
  347. remove_onion_service hubzilla ${HUBZILLA_ONION_PORT}
  348. sed -i '/install_hubzilla/d' $COMPLETION_FILE
  349. sed -i '/Hubzilla /d' $COMPLETION_FILE
  350. echo $'Hubzilla was removed'
  351. }
  352. function install_hubzilla {
  353. if [ ! $ONION_ONLY ]; then
  354. ONION_ONLY='no'
  355. fi
  356. if grep -q "ONION_ONLY" $CONFIGURATION_FILE; then
  357. ONION_ONLY=$(grep "ONION_ONLY" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
  358. fi
  359. if grep -q "HUBZILLA_DOMAIN_NAME" $CONFIGURATION_FILE; then
  360. HUBZILLA_DOMAIN_NAME=$(grep "HUBZILLA_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
  361. fi
  362. if grep -q "HUBZILLA_CODE" $CONFIGURATION_FILE; then
  363. HUBZILLA_CODE=$(grep "HUBZILLA_CODE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
  364. fi
  365. if grep -q "DDNS_PROVIDER" $CONFIGURATION_FILE; then
  366. DDNS_PROVIDER=$(grep "DDNS_PROVIDER" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
  367. fi
  368. if [ ! $HUBZILLA_DOMAIN_NAME ]; then
  369. return
  370. fi
  371. if [[ $ONION_ONLY != "no" ]]; then
  372. return
  373. fi
  374. if [[ $(app_is_installed hubzilla) == "1" ]]; then
  375. return
  376. fi
  377. HUBZILLA_PATH=/var/www/$HUBZILLA_DOMAIN_NAME/htdocs
  378. function_check install_mariadb
  379. install_mariadb
  380. function_check get_mariadb_password
  381. get_mariadb_password
  382. function_check repair_databases_script
  383. repair_databases_script
  384. apt-get -y install php5-common php5-cli php5-curl php5-gd php5-mysql php5-mcrypt git
  385. apt-get -y install php5-dev imagemagick php5-imagick
  386. apt-get -y install php5-memcached
  387. if [ ! -d /var/www/$HUBZILLA_DOMAIN_NAME ]; then
  388. mkdir /var/www/$HUBZILLA_DOMAIN_NAME
  389. fi
  390. if [ ! -d $HUBZILLA_PATH ]; then
  391. mkdir $HUBZILLA_PATH
  392. fi
  393. if [ ! -f $HUBZILLA_PATH/index.php ]; then
  394. cd $INSTALL_DIR
  395. function_check git_clone
  396. git_clone $HUBZILLA_REPO hubzilla
  397. git checkout $HUBZILLA_COMMIT -b $HUBZILLA_COMMIT
  398. if ! grep -q "Hubzilla commit" $COMPLETION_FILE; then
  399. echo "Hubzilla commit:$HUBZILLA_COMMIT" >> $COMPLETION_FILE
  400. else
  401. sed -i "s/Hubzilla commit.*/Hubzilla commit:$HUBZILLA_COMMIT/g" $COMPLETION_FILE
  402. fi
  403. rm -rf $HUBZILLA_PATH
  404. mv hubzilla $HUBZILLA_PATH
  405. git_clone $HUBZILLA_ADDONS_REPO $HUBZILLA_PATH/addon
  406. cd $HUBZILLA_PATH/addon
  407. git checkout $HUBZILLA_ADDONS_COMMIT -b $HUBZILLA_ADDONS_COMMIT
  408. if ! grep -q "Hubzilla addons commit" $COMPLETION_FILE; then
  409. echo "Hubzilla addons commit:$HUBZILLA_ADDONS_COMMIT" >> $COMPLETION_FILE
  410. else
  411. sed -i "s/Hubzilla addons commit.*/Hubzilla addons commit:$HUBZILLA_ADDONS_COMMIT/g" $COMPLETION_FILE
  412. fi
  413. # some extra themes
  414. git_clone $HUBZILLA_THEMES_REPO $HUBZILLA_PATH/redmatrix-themes1
  415. cp -r $HUBZILLA_PATH/redmatrix-themes1/* $HUBZILLA_PATH/view/theme/
  416. chown -R www-data:www-data $HUBZILLA_PATH
  417. fi
  418. HUBZILLA_ONION_HOSTNAME=
  419. if [[ $ONION_ONLY != "no" ]]; then
  420. HUBZILLA_ONION_HOSTNAME=$(add_onion_service hubzilla 80 ${HUBZILLA_ONION_PORT})
  421. echo "Hubzilla onion domain:${HUBZILLA_ONION_HOSTNAME}" >> $COMPLETION_FILE
  422. fi
  423. hubzilla_create_database
  424. if ! grep -q "$HUBZILLA_PATH" /etc/crontab; then
  425. echo "12,22,32,42,52 * * * * root cd $HUBZILLA_PATH; /usr/bin/timeout 500 /usr/bin/php include/poller.php" >> /etc/crontab
  426. fi
  427. function_check add_ddns_domain
  428. add_ddns_domain $HUBZILLA_DOMAIN_NAME
  429. if [[ $ONION_ONLY == "no" ]]; then
  430. function_check nginx_http_redirect
  431. nginx_http_redirect $HUBZILLA_DOMAIN_NAME
  432. echo 'server {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  433. echo ' listen 443 ssl;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  434. echo " root $HUBZILLA_PATH;" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  435. echo " server_name $HUBZILLA_DOMAIN_NAME;" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  436. echo " error_log /var/log/nginx/${HUBZILLA_DOMAIN_NAME}_error_ssl.log $WEBSERVER_LOG_LEVEL;" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  437. echo ' index index.php;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  438. echo ' charset utf-8;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  439. echo ' access_log off;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  440. function_check nginx_limits
  441. nginx_limits $HUBZILLA_DOMAIN_NAME
  442. function_check nginx_ssl
  443. nginx_ssl $HUBZILLA_DOMAIN_NAME
  444. function_check nginx_disable_sniffing
  445. nginx_disable_sniffing $HUBZILLA_DOMAIN_NAME
  446. echo ' add_header Strict-Transport-Security max-age=15768000;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  447. echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  448. echo ' # rewrite to front controller as default rule' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  449. echo ' location / {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  450. echo ' rewrite ^/(.*) /index.php?q=$uri&$args last;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  451. echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  452. echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  453. echo " # make sure webfinger and other well known services aren't blocked" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  454. echo ' # by denying dot files and rewrite request to the front controller' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  455. echo ' location ^~ /.well-known/ {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  456. echo ' allow all;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  457. echo ' rewrite ^/(.*) /index.php?q=$uri&$args last;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  458. echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  459. echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  460. echo ' # statically serve these file types when possible' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  461. echo ' # otherwise fall back to front controller' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  462. echo ' # allow browser to cache them' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  463. echo ' # added .htm for advanced source code editor library' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  464. echo ' location ~* \.(jpg|jpeg|gif|png|ico|css|js|htm|html|ttf|woff|svg)$ {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  465. echo ' expires 30d;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  466. echo ' try_files $uri /index.php?q=$uri&$args;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  467. echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  468. echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  469. echo ' # block these file types' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  470. echo ' location ~* \.(tpl|md|tgz|log|out)$ {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  471. echo ' deny all;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  472. echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  473. echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  474. echo ' # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  475. echo ' # or a unix socket' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  476. echo ' location ~* \.php$ {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  477. echo ' # Zero-day exploit defense.' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  478. echo ' # http://forum.nginx.org/read.php?2,88845,page=3' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  479. echo " # Won't work properly (404 error) if the file is not stored on this" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  480. echo " # server, which is entirely possible with php-fpm/php-fcgi." >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  481. echo " # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  482. echo " # another machine. And then cross your fingers that you won't get hacked." >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  483. echo ' try_files $uri $uri/ /index.php;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  484. echo ' # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  485. echo ' fastcgi_split_path_info ^(.+\.php)(/.+)$;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  486. echo ' # With php5-cgi alone:' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  487. echo ' # fastcgi_pass 127.0.0.1:9000;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  488. echo ' # With php5-fpm:' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  489. echo ' fastcgi_pass unix:/var/run/php5-fpm.sock;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  490. echo ' include fastcgi_params;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  491. echo ' fastcgi_index index.php;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  492. echo ' fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  493. echo ' fastcgi_read_timeout 300;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  494. echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  495. echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  496. echo ' # deny access to all dot files' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  497. echo ' location ~ /\. {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  498. echo ' deny all;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  499. echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  500. echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  501. echo ' location ~ /\.ht {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  502. echo ' deny all;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  503. echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  504. echo '}' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  505. echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  506. else
  507. echo 'server {' > /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  508. echo " listen 127.0.0.1:${HUBZILLA_ONION_PORT} default_server;" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  509. echo " root $HUBZILLA_PATH;" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  510. echo " server_name $HUBZILLA_ONION_HOSTNAME;" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  511. echo " error_log /var/log/nginx/${HUBZILLA_DOMAIN_NAME}_error_ssl.log $WEBSERVER_LOG_LEVEL;" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  512. echo ' index index.php;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  513. echo ' charset utf-8;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  514. echo ' access_log off;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  515. nginx_limits $HUBZILLA_DOMAIN_NAME
  516. nginx_disable_sniffing $HUBZILLA_DOMAIN_NAME
  517. echo ' add_header Strict-Transport-Security max-age=15768000;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  518. echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  519. echo ' # rewrite to front controller as default rule' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  520. echo ' location / {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  521. echo ' rewrite ^/(.*) /index.php?q=$uri&$args last;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  522. echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  523. echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  524. echo " # make sure webfinger and other well known services aren't blocked" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  525. echo ' # by denying dot files and rewrite request to the front controller' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  526. echo ' location ^~ /.well-known/ {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  527. echo ' allow all;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  528. echo ' rewrite ^/(.*) /index.php?q=$uri&$args last;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  529. echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  530. echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  531. echo ' # statically serve these file types when possible' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  532. echo ' # otherwise fall back to front controller' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  533. echo ' # allow browser to cache them' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  534. echo ' # added .htm for advanced source code editor library' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  535. echo ' location ~* \.(jpg|jpeg|gif|png|ico|css|js|htm|html|ttf|woff|svg)$ {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  536. echo ' expires 30d;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  537. echo ' try_files $uri /index.php?q=$uri&$args;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  538. echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  539. echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  540. echo ' # block these file types' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  541. echo ' location ~* \.(tpl|md|tgz|log|out)$ {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  542. echo ' deny all;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  543. echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  544. echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  545. echo ' # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  546. echo ' # or a unix socket' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  547. echo ' location ~* \.php$ {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  548. echo ' # Zero-day exploit defense.' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  549. echo ' # http://forum.nginx.org/read.php?2,88845,page=3' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  550. echo " # Won't work properly (404 error) if the file is not stored on this" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  551. echo " # server, which is entirely possible with php-fpm/php-fcgi." >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  552. echo " # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  553. echo " # another machine. And then cross your fingers that you won't get hacked." >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  554. echo ' try_files $uri $uri/ /index.php;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  555. echo ' # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  556. echo ' fastcgi_split_path_info ^(.+\.php)(/.+)$;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  557. echo ' # With php5-cgi alone:' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  558. echo ' # fastcgi_pass 127.0.0.1:9000;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  559. echo ' # With php5-fpm:' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  560. echo ' fastcgi_pass unix:/var/run/php5-fpm.sock;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  561. echo ' include fastcgi_params;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  562. echo ' fastcgi_index index.php;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  563. echo ' fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  564. echo ' fastcgi_read_timeout 300;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  565. echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  566. echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  567. echo ' # deny access to all dot files' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  568. echo ' location ~ /\. {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  569. echo ' deny all;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  570. echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  571. echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  572. echo ' location ~ /\.ht {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  573. echo ' deny all;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  574. echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  575. echo '}' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
  576. fi
  577. function_check configure_php
  578. configure_php
  579. function_check create_site_certificate
  580. create_site_certificate $HUBZILLA_DOMAIN_NAME 'yes'
  581. if [ ! -d $HUBZILLA_PATH/view/tpl/smarty3 ]; then
  582. mkdir $HUBZILLA_PATH/view/tpl/smarty3
  583. fi
  584. if [ ! -d "$HUBZILLA_PATH/store" ]; then
  585. mkdir "$HUBZILLA_PATH/store"
  586. fi
  587. if [ ! -d "$HUBZILLA_PATH/store/[data]" ]; then
  588. mkdir "$HUBZILLA_PATH/store/[data]"
  589. fi
  590. if [ ! -d "$HUBZILLA_PATH/store/[data]/smarty3" ]; then
  591. mkdir "$HUBZILLA_PATH/store/[data]/smarty3"
  592. chmod 777 "$HUBZILLA_PATH/store/[data]/smarty3"
  593. fi
  594. chmod 777 $HUBZILLA_PATH/view/tpl
  595. chown -R www-data:www-data "$HUBZILLA_PATH/store"
  596. chmod 777 $HUBZILLA_PATH/view/tpl/smarty3
  597. # Ensure that the database gets backed up locally, if remote
  598. # backups are not being used
  599. function_check backup_databases_script_header
  600. backup_databases_script_header
  601. function_check backup_database_local
  602. backup_database_local hubzilla
  603. chown -R www-data:www-data $HUBZILLA_PATH
  604. function_check nginx_ensite
  605. nginx_ensite $HUBZILLA_DOMAIN_NAME
  606. # initialize the database
  607. if [ ! -f $HUBZILLA_PATH/install/schema_mysql.sql ]; then
  608. echo $'No database schema found for hubzilla'
  609. exit 252782
  610. fi
  611. function_check initialise_database
  612. initialise_database hubzilla $HUBZILLA_PATH/install/schema_mysql.sql
  613. # create the config file
  614. echo '<?php' > $HUBZILLA_PATH/.htconfig.php
  615. echo "\$db_host = 'localhost';" >> $HUBZILLA_PATH/.htconfig.php
  616. echo "\$db_port = '0';" >> $HUBZILLA_PATH/.htconfig.php
  617. echo "\$db_user = 'root';" >> $HUBZILLA_PATH/.htconfig.php
  618. echo "\$db_pass = '${MARIADB_PASSWORD}';" >> $HUBZILLA_PATH/.htconfig.php
  619. echo "\$db_data = 'hubzilla';" >> $HUBZILLA_PATH/.htconfig.php
  620. echo "\$db_type = '0';" >> $HUBZILLA_PATH/.htconfig.php
  621. echo "\$default_timezone = 'Europe/London';" >> $HUBZILLA_PATH/.htconfig.php
  622. if [[ $ONION_ONLY == 'no' ]]; then
  623. echo "\$a->config['system']['baseurl'] = 'https://${HUBZILLA_DOMAIN_NAME}';" >> $HUBZILLA_PATH/.htconfig.php
  624. else
  625. echo "\$a->config['system']['baseurl'] = 'http://${HUBZILLA_ONION_HOSTNAME}';" >> $HUBZILLA_PATH/.htconfig.php
  626. fi
  627. echo "\$a->config['system']['sitename'] = \"Hubzilla\";" >> $HUBZILLA_PATH/.htconfig.php
  628. HUBZILLA_LOCATION_HASH="$(create_password 30)"
  629. echo "\$a->config['system']['location_hash'] = '${HUBZILLA_LOCATION_HASH}';" >> $HUBZILLA_PATH/.htconfig.php
  630. echo "\$a->config['system']['register_policy'] = REGISTER_OPEN;" >> $HUBZILLA_PATH/.htconfig.php
  631. echo "\$a->config['system']['register_text'] = '';" >> $HUBZILLA_PATH/.htconfig.php
  632. echo "\$a->config['system']['admin_email'] = '${MY_EMAIL_ADDRESS}';" >> $HUBZILLA_PATH/.htconfig.php
  633. echo "\$a->config['system']['verify_email'] = 1;" >> $HUBZILLA_PATH/.htconfig.php
  634. echo "\$a->config['system']['access_policy'] = ACCESS_PRIVATE;" >> $HUBZILLA_PATH/.htconfig.php
  635. echo "\$a->config['system']['sellpage'] = '';" >> $HUBZILLA_PATH/.htconfig.php
  636. echo "\$a->config['system']['max_import_size'] = 200000;" >> $HUBZILLA_PATH/.htconfig.php
  637. echo "\$a->config['system']['php_path'] = '/usr/bin/php';" >> $HUBZILLA_PATH/.htconfig.php
  638. echo "\$a->config['system']['directory_mode'] = DIRECTORY_MODE_NORMAL;" >> $HUBZILLA_PATH/.htconfig.php
  639. echo "\$a->config['system']['theme'] = 'redbasic';" >> $HUBZILLA_PATH/.htconfig.php
  640. chown www-data:www-data $HUBZILLA_PATH/.htconfig.php
  641. chmod 755 $HUBZILLA_PATH/.htconfig.php
  642. systemctl restart php5-fpm
  643. systemctl restart nginx
  644. systemctl restart cron
  645. ${PROJECT_NAME}-addemail -u $MY_USERNAME -e "noreply@$HUBZILLA_DOMAIN_NAME" -g hubzilla --public no
  646. echo "Hubzilla domain:${HUBZILLA_DOMAIN_NAME}" >> $COMPLETION_FILE
  647. install_completed hubzilla
  648. }
  649. # NOTE: deliberately there is no "exit 0"