freedombone-app-movim 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. #!/bin/bash
  2. #
  3. # .---. . .
  4. # | | |
  5. # |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
  6. # | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
  7. # ' ' --' --' -' - -' ' ' -' -' -' ' - --'
  8. #
  9. # Freedom in the Cloud
  10. #
  11. # movim application
  12. #
  13. # License
  14. # =======
  15. #
  16. # Copyright (C) 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 chat'
  31. IN_DEFAULT_INSTALL=0
  32. SHOW_ON_ABOUT=1
  33. MOVIM_DOMAIN_NAME=
  34. MOVIM_CODE=
  35. MOVIM_ONION_PORT=8117
  36. MOVIM_REPO="https://github.com/movim/movim"
  37. MOVIM_COMMIT='add1a247804eb0e34fc28a74c2eeea16792ffa8e'
  38. MOVIM_ADMIN_PASSWORD=
  39. MOVIM_DAEMON_PORT=8081
  40. movim_variables=(ONION_ONLY
  41. MOVIM_DOMAIN_NAME
  42. MOVIM_CODE
  43. DDNS_PROVIDER
  44. MY_USERNAME)
  45. function remove_user_movim {
  46. remove_username="$1"
  47. ${PROJECT_NAME}-pass -u $remove_username --rmapp movim
  48. }
  49. function add_user_movim {
  50. new_username="$1"
  51. new_user_password="$2"
  52. ${PROJECT_NAME}-pass -u $new_username -a movim -p "$new_user_password"
  53. echo '0'
  54. }
  55. function install_interactive_movim {
  56. if [ ! $ONION_ONLY ]; then
  57. ONION_ONLY='no'
  58. fi
  59. if [[ $ONION_ONLY != "no" ]]; then
  60. MOVIM_DOMAIN_NAME='movim.local'
  61. else
  62. MOVIM_DETAILS_COMPLETE=
  63. while [ ! $MOVIM_DETAILS_COMPLETE ]
  64. do
  65. data=$(tempfile 2>/dev/null)
  66. trap "rm -f $data" 0 1 2 5 15
  67. if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
  68. dialog --backtitle $"Freedombone Configuration" \
  69. --title $"Movim Configuration" \
  70. --form $"\nPlease enter your Movim details.\n\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 12 65 2 \
  71. $"Domain:" 1 1 "$(grep 'MOVIM_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 25 33 40 \
  72. $"Code:" 2 1 "$(grep 'MOVIM_CODE' temp.cfg | awk -F '=' '{print $2}')" 2 25 33 255 \
  73. 2> $data
  74. else
  75. dialog --backtitle $"Freedombone Configuration" \
  76. --title $"Movim Configuration" \
  77. --form $"\nPlease enter your Movim details.\n\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 12 65 2 \
  78. $"Domain:" 1 1 "$(grep 'MOVIM_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 25 33 40 \
  79. 2> $data
  80. fi
  81. sel=$?
  82. case $sel in
  83. 1) exit 1;;
  84. 255) exit 1;;
  85. esac
  86. MOVIM_DOMAIN_NAME=$(cat $data | sed -n 1p)
  87. if [ $MOVIM_DOMAIN_NAME ]; then
  88. TEST_DOMAIN_NAME=$MOVIM_DOMAIN_NAME
  89. validate_domain_name
  90. if [[ $TEST_DOMAIN_NAME != $MOVIM_DOMAIN_NAME ]]; then
  91. MOVIM_DOMAIN_NAME=
  92. dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
  93. else
  94. if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
  95. MOVIM_CODE=$(cat $data | sed -n 2p)
  96. validate_freedns_code "$MOVIM_CODE"
  97. if [ ! $VALID_CODE ]; then
  98. MOVIM_DOMAIN_NAME=
  99. fi
  100. fi
  101. fi
  102. fi
  103. if [ $MOVIM_DOMAIN_NAME ]; then
  104. MOVIM_DETAILS_COMPLETE="yes"
  105. fi
  106. done
  107. # save the results in the config file
  108. write_config_param "MOVIM_CODE" "$MOVIM_CODE"
  109. fi
  110. write_config_param "MOVIM_DOMAIN_NAME" "$MOVIM_DOMAIN_NAME"
  111. APP_INSTALLED=1
  112. }
  113. function change_password_movim {
  114. curr_username="$1"
  115. new_user_password="$2"
  116. read_config_param ${MOVIM_DOMAIN_NAME}
  117. ${PROJECT_NAME}-pass -u "$curr_username" -a movim -p "$new_user_password"
  118. }
  119. function movim_create_database {
  120. if [ -f $IMAGE_PASSWORD_FILE ]; then
  121. MOVIM_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
  122. else
  123. if [ ! $MOVIM_ADMIN_PASSWORD ]; then
  124. MOVIM_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
  125. fi
  126. fi
  127. if [ ! $MOVIM_ADMIN_PASSWORD ]; then
  128. return
  129. fi
  130. function_check create_database
  131. create_database movim "$MOVIM_ADMIN_PASSWORD" $MY_USERNAME
  132. }
  133. function reconfigure_movim {
  134. echo -n ''
  135. }
  136. function upgrade_movim {
  137. if grep -q "movim domain" $COMPLETION_FILE; then
  138. MOVIM_DOMAIN_NAME=$(get_completion_param "movim domain")
  139. fi
  140. # update to the next commit
  141. function_check set_repo_commit
  142. set_repo_commit /var/www/$MOVIM_DOMAIN_NAME/htdocs "movim commit" "$MOVIM_COMMIT" $MOVIM_REPO
  143. cd /var/www/${MOVIM_DOMAIN_NAME}/htdocs
  144. php composer.phar install
  145. chown -R www-data:www-data /var/www/${MOVIM_DOMAIN_NAME}/htdocs
  146. }
  147. function backup_local_movim {
  148. MOVIM_DOMAIN_NAME='movim'
  149. if grep -q "movim domain" $COMPLETION_FILE; then
  150. MOVIM_DOMAIN_NAME=$(get_completion_param "movim domain")
  151. fi
  152. source_directory=/var/www/${MOVIM_DOMAIN_NAME}/htdocs
  153. if [ -d $source_directory ]; then
  154. dest_directory=movim
  155. function_check suspend_site
  156. suspend_site ${MOVIM_DOMAIN_NAME}
  157. function_check backup_directory_to_usb
  158. backup_directory_to_usb $source_directory $dest_directory
  159. function_check backup_database_to_usb
  160. backup_database_to_usb movim
  161. function_check restart_site
  162. restart_site
  163. fi
  164. }
  165. function restore_local_movim {
  166. if ! grep -q "movim domain" $COMPLETION_FILE; then
  167. return
  168. fi
  169. MOVIM_DOMAIN_NAME=$(get_completion_param "movim domain")
  170. if [ $MOVIM_DOMAIN_NAME ]; then
  171. echo $"Restoring movim"
  172. temp_restore_dir=/root/tempmovim
  173. movim_dir=/var/www/${MOVIM_DOMAIN_NAME}/htdocs
  174. # stop the daemons
  175. cd $movim_dir
  176. su -c "sh scripts/stopdaemons.sh" -s /bin/sh www-data
  177. function_check movim_create_database
  178. movim_create_database
  179. restore_database movim ${MOVIM_DOMAIN_NAME}
  180. if [ -d $temp_restore_dir ]; then
  181. rm -rf $temp_restore_dir
  182. fi
  183. echo $"Restore of movim complete"
  184. fi
  185. }
  186. function backup_remote_movim {
  187. if grep -q "movim domain" $COMPLETION_FILE; then
  188. MOVIM_DOMAIN_NAME=$(get_completion_param "movim domain")
  189. temp_backup_dir=/var/www/${MOVIM_DOMAIN_NAME}/htdocs
  190. if [ -d $temp_backup_dir ]; then
  191. function_check suspend_site
  192. suspend_site ${MOVIM_DOMAIN_NAME}
  193. function_check backup_database_to_friend
  194. backup_database_to_friend movim
  195. echo $"Backing up GNU social installation"
  196. function_check backup_directory_to_friend
  197. backup_directory_to_friend $temp_backup_dir movim
  198. function_check restart_site
  199. restart_site
  200. else
  201. echo $"movim domain specified but not found in ${temp_backup_dir}"
  202. fi
  203. fi
  204. }
  205. function restore_remote_movim {
  206. if grep -q "movim domain" $COMPLETION_FILE; then
  207. echo $"Restoring movim"
  208. MOVIM_DOMAIN_NAME=$(get_completion_param "movim domain")
  209. # stop the daemons
  210. cd /var/www/${MOVIM_DOMAIN_NAME}/htdocs
  211. su -c "sh scripts/stopdaemons.sh" -s /bin/sh www-data
  212. function_check movim_create_database
  213. movim_create_database
  214. function_check restore_database_from_friend
  215. restore_database_from_friend movim ${MOVIM_DOMAIN_NAME}
  216. if [ -d /root/tempmovim ]; then
  217. rm -rf /root/tempmovim
  218. fi
  219. echo $"Restore of movim complete"
  220. fi
  221. }
  222. function remove_movim {
  223. read_config_param "MOVIM_DOMAIN_NAME"
  224. if [ ${#MOVIM_DOMAIN_NAME} -eq 0 ]; then
  225. return
  226. fi
  227. read_config_param "MY_USERNAME"
  228. echo "Removing $MOVIM_DOMAIN_NAME"
  229. nginx_dissite $MOVIM_DOMAIN_NAME
  230. remove_certs $MOVIM_DOMAIN_NAME
  231. if [ -d /var/www/$MOVIM_DOMAIN_NAME ]; then
  232. rm -rf /var/www/$MOVIM_DOMAIN_NAME
  233. fi
  234. if [ -f /etc/nginx/sites-available/$MOVIM_DOMAIN_NAME ]; then
  235. rm /etc/nginx/sites-available/$MOVIM_DOMAIN_NAME
  236. fi
  237. function_check drop_database
  238. drop_database movim
  239. function_check remove_onion_service
  240. remove_onion_service movim ${MOVIM_ONION_PORT}
  241. if grep -q "movim" /etc/crontab; then
  242. sed -i "/movim/d" /etc/crontab
  243. fi
  244. remove_app movim
  245. remove_completion_param install_movim
  246. sed -i '/movim/d' $COMPLETION_FILE
  247. remove_backup_database_local movim
  248. function_check remove_ddns_domain
  249. remove_ddns_domain $MOVIM_DOMAIN_NAME
  250. }
  251. function install_movim {
  252. if [ ! $MOVIM_DOMAIN_NAME ]; then
  253. echo $'No domain name was given for movim'
  254. exit 72572
  255. fi
  256. movim_hourly_script movim $MOVIM_DOMAIN_NAME
  257. function_check install_mariadb
  258. install_mariadb
  259. function_check get_mariadb_password
  260. get_mariadb_password
  261. function_check repair_databases_script
  262. repair_databases_script
  263. apt-get -yq install php-gettext php5-curl php5-gd php5-mysql git curl php-xml-parser
  264. apt-get -yq install php5-memcached php5-intl exiftool
  265. if [ ! -d /var/www/$MOVIM_DOMAIN_NAME ]; then
  266. mkdir /var/www/$MOVIM_DOMAIN_NAME
  267. fi
  268. if [ ! -d /var/www/$MOVIM_DOMAIN_NAME/htdocs ]; then
  269. function_check git_clone
  270. git_clone $MOVIM_REPO /var/www/$MOVIM_DOMAIN_NAME/htdocs
  271. if [ ! -d /var/www/$MOVIM_DOMAIN_NAME/htdocs ]; then
  272. echo $'Unable to clone movim repo'
  273. exit 76285
  274. fi
  275. fi
  276. cd /var/www/$MOVIM_DOMAIN_NAME/htdocs
  277. git checkout $MOVIM_COMMIT -b $MOVIM_COMMIT
  278. set_completion_param "movim commit" "$MOVIM_COMMIT"
  279. curl -sS https://getcomposer.org/installer | php
  280. php composer.phar install
  281. cd /var/www/$MOVIM_DOMAIN_NAME/htdocs/config
  282. cp db.example.inc.php db.inc.php
  283. sed -i "s|'username'.*|'username' => 'root',|g" db.inc.php
  284. sed -i "s|'password'.*|'password' => '$MARIADB_PASSWORD',|g" db.inc.php
  285. sed -i "s|'database'.*|'database' => 'movim'|g" db.inc.php
  286. chmod u+rwx /var/www/$MOVIM_DOMAIN_NAME/htdocs
  287. chown -R www-data:www-data /var/www/$MOVIM_DOMAIN_NAME/htdocs
  288. function_check movim_create_database
  289. movim_create_database
  290. function_check add_ddns_domain
  291. add_ddns_domain $MOVIM_DOMAIN_NAME
  292. MOVIM_ONION_HOSTNAME=$(add_onion_service movim 80 ${MOVIM_ONION_PORT})
  293. echo '[Unit]' > /etc/systemd/system/movim.service
  294. echo 'Description=Movim daemon' >> /etc/systemd/system/movim.service
  295. echo 'After=network.target nginx.target' >> /etc/systemd/system/movim.service
  296. echo '' >> /etc/systemd/system/movim.service
  297. echo '[Service]' >> /etc/systemd/system/movim.service
  298. echo 'Type=simple' >> /etc/systemd/system/movim.service
  299. echo 'User=www-data' >> /etc/systemd/system/movim.service
  300. echo "WorkingDirectory=/var/www/$MOVIM_DOMAIN_NAME/htdocs" >> /etc/systemd/system/movim.service
  301. if [[ $ONION_ONLY == 'no' ]]; then
  302. echo "ExecStart=/usr/bin/php /var/www/$MOVIM_DOMAIN_NAME/htdocs/daemon.php start --url=https://$MOVIM_DOMAIN_NAME --port=$MOVIM_DAEMON_PORT" >> /etc/systemd/system/movim.service
  303. else
  304. echo "ExecStart=/usr/bin/php /var/www/$MOVIM_DOMAIN_NAME/htdocs/daemon.php start --url=http://$MOVIM_ONION_HOSTNAME --port=$MOVIM_DAEMON_PORT" >> /etc/systemd/system/movim.service
  305. fi
  306. echo 'Restart=on-failure' >> /etc/systemd/system/movim.service
  307. echo 'RestartSec=10' >> /etc/systemd/system/movim.service
  308. echo '' >> /etc/systemd/system/movim.service
  309. echo '[Install]' >> /etc/systemd/system/movim.service
  310. echo 'WantedBy=multi-user.target' >> /etc/systemd/system/movim.service
  311. systemctl enable movim
  312. systemctl daemon-reload
  313. movim_nginx_site=/etc/nginx/sites-available/$MOVIM_DOMAIN_NAME
  314. if [[ $ONION_ONLY == "no" ]]; then
  315. function_check nginx_http_redirect
  316. nginx_http_redirect $MOVIM_DOMAIN_NAME "index index.php"
  317. echo 'server {' >> $movim_nginx_site
  318. echo ' listen 443 ssl;' >> $movim_nginx_site
  319. echo ' listen [::]:443 ssl;' >> $movim_nginx_site
  320. echo " server_name $MOVIM_DOMAIN_NAME;" >> $movim_nginx_site
  321. echo '' >> $movim_nginx_site
  322. function_check nginx_compress
  323. nginx_compress $MOVIM_DOMAIN_NAME
  324. echo '' >> $movim_nginx_site
  325. echo ' # Security' >> $movim_nginx_site
  326. function_check nginx_ssl
  327. nginx_ssl $MOVIM_DOMAIN_NAME
  328. function_check nginx_disable_sniffing
  329. nginx_disable_sniffing $MOVIM_DOMAIN_NAME
  330. echo ' add_header Strict-Transport-Security max-age=15768000;' >> $movim_nginx_site
  331. echo '' >> $movim_nginx_site
  332. echo ' # Logs' >> $movim_nginx_site
  333. echo ' access_log /dev/null;' >> $movim_nginx_site
  334. echo ' error_log /dev/null;' >> $movim_nginx_site
  335. echo '' >> $movim_nginx_site
  336. echo ' # Root' >> $movim_nginx_site
  337. echo " root /var/www/$MOVIM_DOMAIN_NAME/htdocs;" >> $movim_nginx_site
  338. echo '' >> $movim_nginx_site
  339. echo ' # Index' >> $movim_nginx_site
  340. echo ' index index.php;' >> $movim_nginx_site
  341. echo '' >> $movim_nginx_site
  342. echo ' # PHP' >> $movim_nginx_site
  343. echo ' location ~ \.php {' >> $movim_nginx_site
  344. echo ' include snippets/fastcgi-php.conf;' >> $movim_nginx_site
  345. echo ' fastcgi_pass unix:/var/run/php5-fpm.sock;' >> $movim_nginx_site
  346. echo ' }' >> $movim_nginx_site
  347. echo '' >> $movim_nginx_site
  348. echo ' # Location' >> $movim_nginx_site
  349. echo ' location / {' >> $movim_nginx_site
  350. function_check nginx_limits
  351. nginx_limits $MOVIM_DOMAIN_NAME '15m'
  352. echo ' try_files $uri $uri/ @movim;' >> $movim_nginx_site
  353. echo ' }' >> $movim_nginx_site
  354. echo '' >> $movim_nginx_site
  355. echo ' location /ws/ {' >> $movim_nginx_site
  356. echo " proxy_pass http://localhost:${MOVIM_DAEMON_PORT}/;" >> $movim_nginx_site
  357. echo ' proxy_http_version 1.1;' >> $movim_nginx_site
  358. echo ' proxy_set_header Upgrade $http_upgrade;' >> $movim_nginx_site
  359. echo ' proxy_set_header Connection "Upgrade";' >> $movim_nginx_site
  360. echo ' proxy_set_header Host $host;' >> $movim_nginx_site
  361. echo ' proxy_set_header X-Real-IP $remote_addr;' >> $movim_nginx_site
  362. echo ' proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;' >> $movim_nginx_site
  363. echo ' proxy_set_header X-Forwarded-Proto https;' >> $movim_nginx_site
  364. echo ' proxy_redirect off;' >> $movim_nginx_site
  365. echo ' }' >> $movim_nginx_site
  366. echo '' >> $movim_nginx_site
  367. echo ' # Fancy URLs' >> $movim_nginx_site
  368. echo ' location @movim {' >> $movim_nginx_site
  369. echo ' rewrite ^(.*)$ /index.php?p=$1 last;' >> $movim_nginx_site
  370. echo ' }' >> $movim_nginx_site
  371. echo '' >> $movim_nginx_site
  372. echo ' # Restrict access that is unnecessary anyway' >> $movim_nginx_site
  373. echo ' location ~ /\.(ht|git) {' >> $movim_nginx_site
  374. echo ' deny all;' >> $movim_nginx_site
  375. echo ' }' >> $movim_nginx_site
  376. echo '' >> $movim_nginx_site
  377. echo '}' >> $movim_nginx_site
  378. else
  379. echo -n '' > $movim_nginx_site
  380. fi
  381. echo 'server {' >> $movim_nginx_site
  382. echo " listen 127.0.0.1:$MOVIM_ONION_PORT default_server;" >> $movim_nginx_site
  383. echo " server_name $MOVIM_DOMAIN_NAME;" >> $movim_nginx_site
  384. echo '' >> $movim_nginx_site
  385. function_check nginx_compress
  386. nginx_compress $MOVIM_DOMAIN_NAME
  387. echo '' >> $movim_nginx_site
  388. function_check nginx_disable_sniffing
  389. nginx_disable_sniffing $MOVIM_DOMAIN_NAME
  390. echo '' >> $movim_nginx_site
  391. echo ' # Logs' >> $movim_nginx_site
  392. echo ' access_log /dev/null;' >> $movim_nginx_site
  393. echo ' error_log /dev/null;' >> $movim_nginx_site
  394. echo '' >> $movim_nginx_site
  395. echo ' # Root' >> $movim_nginx_site
  396. echo " root /var/www/$MOVIM_DOMAIN_NAME/htdocs;" >> $movim_nginx_site
  397. echo '' >> $movim_nginx_site
  398. echo ' # Index' >> $movim_nginx_site
  399. echo ' index index.php;' >> $movim_nginx_site
  400. echo '' >> $movim_nginx_site
  401. echo ' # PHP' >> $movim_nginx_site
  402. echo ' location ~ \.php {' >> $movim_nginx_site
  403. echo ' include snippets/fastcgi-php.conf;' >> $movim_nginx_site
  404. echo ' fastcgi_pass unix:/var/run/php5-fpm.sock;' >> $movim_nginx_site
  405. echo ' }' >> $movim_nginx_site
  406. echo '' >> $movim_nginx_site
  407. echo ' # Location' >> $movim_nginx_site
  408. echo ' location / {' >> $movim_nginx_site
  409. function_check nginx_limits
  410. nginx_limits $MOVIM_DOMAIN_NAME '15m'
  411. echo ' try_files $uri $uri/ @movim;' >> $movim_nginx_site
  412. echo ' }' >> $movim_nginx_site
  413. echo '' >> $movim_nginx_site
  414. echo ' location /ws/ {' >> $movim_nginx_site
  415. echo " proxy_pass http://localhost:${MOVIM_DAEMON_PORT}/;" >> $movim_nginx_site
  416. echo ' proxy_http_version 1.1;' >> $movim_nginx_site
  417. echo ' proxy_set_header Upgrade $http_upgrade;' >> $movim_nginx_site
  418. echo ' proxy_set_header Connection "Upgrade";' >> $movim_nginx_site
  419. echo ' proxy_set_header Host $host;' >> $movim_nginx_site
  420. echo ' proxy_set_header X-Real-IP $remote_addr;' >> $movim_nginx_site
  421. echo ' proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;' >> $movim_nginx_site
  422. echo ' proxy_set_header X-Forwarded-Proto https;' >> $movim_nginx_site
  423. echo ' proxy_redirect off;' >> $movim_nginx_site
  424. echo ' }' >> $movim_nginx_site
  425. echo '' >> $movim_nginx_site
  426. echo ' # Fancy URLs' >> $movim_nginx_site
  427. echo ' location @movim {' >> $movim_nginx_site
  428. echo ' rewrite ^(.*)$ /index.php?p=$1 last;' >> $movim_nginx_site
  429. echo ' }' >> $movim_nginx_site
  430. echo '' >> $movim_nginx_site
  431. echo ' # Restrict access that is unnecessary anyway' >> $movim_nginx_site
  432. echo ' location ~ /\.(ht|git) {' >> $movim_nginx_site
  433. echo ' deny all;' >> $movim_nginx_site
  434. echo ' }' >> $movim_nginx_site
  435. echo '' >> $movim_nginx_site
  436. echo '}' >> $movim_nginx_site
  437. function_check configure_php
  438. configure_php
  439. function_check create_site_certificate
  440. create_site_certificate $MOVIM_DOMAIN_NAME 'yes'
  441. # Ensure that the database gets backed up locally, if remote
  442. # backups are not being used
  443. function_check backup_databases_script_header
  444. backup_databases_script_header
  445. function_check backup_database_local
  446. backup_database_local movim
  447. function_check nginx_ensite
  448. nginx_ensite $MOVIM_DOMAIN_NAME
  449. ${PROJECT_NAME}-pass -u $MY_USERNAME -a movim -p "$MOVIM_ADMIN_PASSWORD"
  450. set_completion_param "movim domain" "$MOVIM_DOMAIN_NAME"
  451. systemctl start movim
  452. systemctl restart php5-fpm
  453. systemctl restart nginx
  454. APP_INSTALLED=1
  455. }
  456. # NOTE: deliberately there is no "exit 0"