freedombone-app-scuttlebot 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. #!/bin/bash
  2. # _____ _ _
  3. # | __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
  4. # | __| _| -_| -_| . | . | | . | . | | -_|
  5. # |__| |_| |___|___|___|___|_|_|_|___|___|_|_|___|
  6. #
  7. # Freedom in the Cloud
  8. #
  9. # scuttlebot pub application. Enables nat traversal for SSB.
  10. # https://scuttlebot.io
  11. #
  12. # License
  13. # =======
  14. #
  15. # Copyright (C) 2017-2018 Bob Mottram <bob@freedombone.net>
  16. #
  17. # This program is free software: you can redistribute it and/or modify
  18. # it under the terms of the GNU Affero General Public License as published by
  19. # the Free Software Foundation, either version 3 of the License, or
  20. # (at your option) any later version.
  21. #
  22. # This program is distributed in the hope that it will be useful,
  23. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. # GNU Affero General Public License for more details.
  26. #
  27. # You should have received a copy of the GNU Affero General Public License
  28. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  29. VARIANTS='full full-vim social'
  30. IN_DEFAULT_INSTALL=0
  31. SHOW_ON_ABOUT=0
  32. SHOW_ICANN_ADDRESS_ON_ABOUT=0
  33. SCUTTLEBOT_DOMAIN_NAME=
  34. SCUTTLEBOT_CODE=
  35. SCUTTLEBOT_VERSION='11.2.0'
  36. SCUTTLEBOT_PORT=8010
  37. SCUTTLEBOT_ONION_PORT=8623
  38. GIT_SSB_PORT=7718
  39. NGINX_GIT_SSB_PORT=7719
  40. scuttlebot_variables=(MY_USERNAME
  41. SCUTTLEBOT_DOMAIN_NAME
  42. SCUTTLEBOT_CODE
  43. DEFAULT_DOMAIN_NAME
  44. SYSTEM_TYPE)
  45. function logging_on_scuttlebot {
  46. echo -n ''
  47. }
  48. function logging_off_scuttlebot {
  49. echo -n ''
  50. }
  51. function scuttlebot_create_invite {
  52. invite_string=$(su -c "/etc/scuttlebot/node_modules/.bin/sbot invite.create 1" - scuttlebot | sed 's/"//g')
  53. clear
  54. echo -e "\\n\\nYour Scuttlebot invite code is:\\n\\n${invite_string}\\n\\n"
  55. # shellcheck disable=SC2034
  56. read -n1 -r -p $"Press any key to continue..." key
  57. }
  58. function configure_interactive_scuttlebot {
  59. W=(1 $"Create an invite")
  60. while true
  61. do
  62. # shellcheck disable=SC2068
  63. selection=$(dialog --backtitle $"Freedombone Administrator Control Panel" --title $"Scuttlebot" --menu $"Choose an operation, or ESC to exit:" 10 60 2 "${W[@]}" 3>&2 2>&1 1>&3)
  64. if [ ! "$selection" ]; then
  65. break
  66. fi
  67. case $selection in
  68. 1) scuttlebot_create_invite;;
  69. esac
  70. done
  71. }
  72. function remove_user_scuttlebot {
  73. echo -n ''
  74. # remove_username="$1"
  75. }
  76. function add_user_scuttlebot {
  77. # new_username="$1"
  78. # new_user_password="$2"
  79. echo '0'
  80. }
  81. function install_interactive_scuttlebot {
  82. if [[ $ONION_ONLY != "no" ]]; then
  83. SCUTTLEBOT_DOMAIN_NAME='scuttlebot.local'
  84. write_config_param "SCUTTLEBOT_DOMAIN_NAME" "$SCUTTLEBOT_DOMAIN_NAME"
  85. else
  86. function_check interactive_site_details
  87. interactive_site_details scuttlebot
  88. fi
  89. APP_INSTALLED=1
  90. }
  91. function change_password_scuttlebot {
  92. # new_username="$1"
  93. # new_user_password="$2"
  94. echo '0'
  95. }
  96. function reconfigure_scuttlebot {
  97. if [ -d /etc/scuttlebot/.ssb ]; then
  98. systemctl stop scuttlebot
  99. rm -rf /etc/scuttlebot/.ssb
  100. systemctl start scuttlebot
  101. fi
  102. }
  103. function upgrade_scuttlebot {
  104. if ! grep -q 'scuttlebot version:' $"COMPLETION_FILE"; then
  105. return
  106. fi
  107. CURR_SCUTTLEBOT_VERSION=$(get_completion_param "scuttlebot version")
  108. echo "scuttlebot current version: ${CURR_SCUTTLEBOT_VERSION}"
  109. echo "scuttlebot app version: ${SCUTTLEBOT_VERSION}"
  110. if [[ "${CURR_SCUTTLEBOT_VERSION}" == "${SCUTTLEBOT_VERSION}" ]]; then
  111. return
  112. fi
  113. if ! npm upgrade -g scuttlebot@${SCUTTLEBOT_VERSION} --save; then
  114. return
  115. fi
  116. sed -i "s|scuttlebot version.*|scuttlebot version:${SCUTTLEBOT_VERSION}|g" "${COMPLETION_FILE}"
  117. }
  118. function backup_local_scuttlebot {
  119. if [ -d /etc/scuttlebot/.ssb ]; then
  120. systemctl stop scuttlebot
  121. function_check backup_directory_to_usb
  122. backup_directory_to_usb /etc/scuttlebot/.ssb scuttlebot
  123. systemctl start scuttlebot
  124. fi
  125. }
  126. function restore_local_scuttlebot {
  127. if [ -d /etc/scuttlebot ]; then
  128. systemctl stop scuttlebot
  129. temp_restore_dir=/root/tempscuttlebot
  130. function_check restore_directory_from_usb
  131. restore_directory_from_usb $temp_restore_dir scuttlebot
  132. if [ -d $temp_restore_dir/etc/scuttlebot/.ssb ]; then
  133. cp -r $temp_restore_dir/etc/scuttlebot/.ssb /etc/scuttlebot/
  134. else
  135. cp -r $temp_restore_dir/* /etc/scuttlebot/.ssb/*
  136. fi
  137. systemctl start scuttlebot
  138. rm -rf $temp_restore_dir
  139. fi
  140. }
  141. function backup_remote_scuttlebot {
  142. if [ -d /etc/scuttlebot/.ssb ]; then
  143. systemctl stop scuttlebot
  144. function_check backup_directory_to_friend
  145. backup_directory_to_friend /etc/scuttlebot/.ssb scuttlebot
  146. systemctl start scuttlebot
  147. fi
  148. }
  149. function restore_remote_scuttlebot {
  150. if [ -d /etc/scuttlebot ]; then
  151. systemctl stop scuttlebot
  152. temp_restore_dir=/root/tempscuttlebot
  153. function_check restore_directory_from_friend
  154. restore_directory_from_friend $temp_restore_dir scuttlebot
  155. if [ -d $temp_restore_dir/etc/scuttlebot/.ssb ]; then
  156. cp -r $temp_restore_dir/etc/scuttlebot/.ssb /etc/scuttlebot/
  157. else
  158. cp -r $temp_restore_dir/* /etc/scuttlebot/.ssb/*
  159. fi
  160. systemctl start scuttlebot
  161. rm -rf $temp_restore_dir
  162. fi
  163. }
  164. function remove_scuttlebot {
  165. firewall_remove ${SCUTTLEBOT_PORT}
  166. firewall_remove ${GIT_SSB_PORT}
  167. if [ $SCUTTLEBOT_DOMAIN_NAME ]; then
  168. nginx_dissite ${SCUTTLEBOT_DOMAIN_NAME}
  169. rm /etc/nginx/sites-available/${SCUTTLEBOT_DOMAIN_NAME}
  170. fi
  171. systemctl stop git_ssb
  172. systemctl stop scuttlebot
  173. systemctl disable git_ssb
  174. systemctl disable scuttlebot
  175. rm /etc/systemd/system/git_ssb.service
  176. rm /etc/systemd/system/scuttlebot.service
  177. systemctl daemon-reload
  178. userdel -r scuttlebot
  179. if [ -d /etc/scuttlebot ]; then
  180. rm -rf /etc/scuttlebot
  181. fi
  182. if [ -f /usr/bin/git-ssb-create ]; then
  183. rm /usr/bin/git-ssb-create
  184. fi
  185. remove_completion_param install_scuttlebot
  186. sed -i '/scuttlebot /d' "$COMPLETION_FILE"
  187. }
  188. function git_ssb_script {
  189. if [[ "$1" == "mesh" ]]; then
  190. # shellcheck disable=SC2154
  191. git_ssb_script_name=$rootdir/usr/bin/git-ssb-create
  192. git_ssb_daemon_filename=$rootdir/etc/systemd/system/git_ssb.service
  193. else
  194. git_ssb_script_name=/usr/bin/git-ssb-create
  195. git_ssb_daemon_filename=/etc/systemd/system/git_ssb.service
  196. fi
  197. { echo '#!/bin/bash';
  198. echo "reponame=\"\$1\"";
  199. echo '';
  200. echo "if [[ \"\$reponame\" != \"\" ]]; then";
  201. echo " mkdir \$reponame";
  202. echo " cd \$reponame";
  203. echo ' git init';
  204. echo " git ssb create ssb \$reponame";
  205. echo ' git push --tags ssb master';
  206. echo 'fi';
  207. echo 'exit 0'; } > $git_ssb_script_name
  208. chmod +x $git_ssb_script_name
  209. { echo '[Unit]';
  210. echo 'Description=Git SSB (SSB git web interface)';
  211. echo 'After=syslog.target';
  212. echo 'After=network.target';
  213. echo 'After=scuttlebot.target';
  214. echo '';
  215. echo '[Service]';
  216. echo 'Type=simple';
  217. echo 'User=scuttlebot';
  218. echo 'Group=scuttlebot';
  219. echo "WorkingDirectory=/etc/scuttlebot";
  220. echo "ExecStart=/usr/bin/git ssb web --public localhost:$GIT_SSB_PORT";
  221. echo 'Restart=always';
  222. echo 'Environment="USER=scuttlebot"';
  223. echo '';
  224. echo '[Install]';
  225. echo 'WantedBy=multi-user.target'; } > $git_ssb_daemon_filename
  226. }
  227. function scuttlebot_git_setup {
  228. if [[ "$1" == "mesh" ]]; then
  229. if [ ! -d "$rootdir/root/.npm-global/lib/node_modules/git-ssb/node_modules/git-ssb-web/highlight" ]; then
  230. mkdir "$rootdir/root/.npm-global/lib/node_modules/git-ssb/node_modules/git-ssb-web/highlight"
  231. fi
  232. if [ ! -f "$rootdir/root/.npm-global/lib/node_modules/git-ssb/node_modules/highlight.js/styles/foundation.css" ]; then
  233. echo $'Could not find foundation.css'
  234. exit 347687245
  235. fi
  236. cp "$rootdir/root/.npm-global/lib/node_modules/git-ssb/node_modules/highlight.js/styles/foundation.css" "$rootdir/root/.npm-global/lib/node_modules/git-ssb/node_modules/git-ssb-web/highlight/foundation.css"
  237. git_ssb_nginx_site=$rootdir/etc/nginx/sites-available/git_ssb
  238. { echo 'server {';
  239. echo " listen $NGINX_GIT_SSB_PORT default_server;";
  240. echo " server_name P${PEER_ID}.local;";
  241. echo '';
  242. echo ' access_log /dev/null;';
  243. echo ' error_log /dev/null;';
  244. echo '';
  245. echo ' add_header X-XSS-Protection "1; mode=block";';
  246. echo ' add_header X-Content-Type-Options nosniff;';
  247. echo ' add_header X-Frame-Options SAMEORIGIN;'; } > "$git_ssb_nginx_site"
  248. else
  249. if [ ! $SCUTTLEBOT_DOMAIN_NAME ]; then
  250. exit 7357225
  251. fi
  252. if [ ! -d /root/.npm-global/lib/node_modules/git-ssb/node_modules/git-ssb-web/highlight ]; then
  253. mkdir /root/.npm-global/lib/node_modules/git-ssb/node_modules/git-ssb-web/highlight
  254. fi
  255. if [ ! -f /root/.npm-global/lib/node_modules/git-ssb/node_modules/highlight.js/styles/foundation.css ]; then
  256. echo $'Could not find foundation.css'
  257. exit 347687245
  258. fi
  259. cp /root/.npm-global/lib/node_modules/git-ssb/node_modules/highlight.js/styles/foundation.css /root/.npm-global/lib/node_modules/git-ssb/node_modules/git-ssb-web/highlight/foundation.css
  260. git_ssb_nginx_site=/etc/nginx/sites-available/${SCUTTLEBOT_DOMAIN_NAME}
  261. function_check nginx_http_redirect
  262. nginx_http_redirect $SCUTTLEBOT_DOMAIN_NAME "index index.html"
  263. { echo 'server {';
  264. echo ' listen 443 ssl;';
  265. echo ' #listen [::]:443 ssl;';
  266. echo " server_name $SCUTTLEBOT_DOMAIN_NAME;";
  267. echo ''; } >> $git_ssb_nginx_site
  268. function_check nginx_compress
  269. nginx_compress $SCUTTLEBOT_DOMAIN_NAME
  270. echo '' >> "$git_ssb_nginx_site"
  271. echo ' # Security' >> "$git_ssb_nginx_site"
  272. function_check nginx_ssl
  273. nginx_ssl $SCUTTLEBOT_DOMAIN_NAME
  274. function_check nginx_security_options
  275. nginx_security_options $SCUTTLEBOT_DOMAIN_NAME
  276. fi
  277. { echo '';
  278. echo ' root /root/.npm-global/lib/node_modules/git-ssb/node_modules/git-ssb-web;';
  279. echo '';
  280. echo ' location = / {';
  281. echo " proxy_pass http://localhost:${GIT_SSB_PORT};";
  282. echo " proxy_set_header X-Real-IP \$remote_addr;";
  283. echo " proxy_set_header Host \$host;";
  284. echo " proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;";
  285. echo ' proxy_http_version 1.1;';
  286. echo " proxy_set_header Upgrade \$http_upgrade;";
  287. echo ' proxy_set_header Connection upgrade;';
  288. echo ' }';
  289. echo '}'; } >> $git_ssb_nginx_site
  290. if [ "$SCUTTLEBOT_ONION_HOSTNAME" ]; then
  291. { echo '';
  292. echo 'server {';
  293. echo " listen 127.0.0.1:${SCUTTLEBOT_ONION_PORT} default_server;";
  294. echo " server_name ${SCUTTLEBOT_ONION_HOSTNAME};";
  295. echo '';
  296. echo ' access_log /dev/null;';
  297. echo ' error_log /dev/null;';
  298. echo '';
  299. echo ' add_header X-XSS-Protection "1; mode=block";';
  300. echo ' add_header X-Content-Type-Options nosniff;';
  301. echo ' add_header X-Frame-Options SAMEORIGIN;';
  302. echo '';
  303. echo ' root /root/.npm-global/lib/node_modules/git-ssb/node_modules/git-ssb-web;';
  304. echo '';
  305. echo ' location = / {';
  306. echo " proxy_pass http://localhost:${GIT_SSB_PORT};";
  307. echo " proxy_set_header X-Real-IP \$remote_addr;";
  308. echo " proxy_set_header Host \$host;";
  309. echo " proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;";
  310. echo ' proxy_http_version 1.1;';
  311. echo " proxy_set_header Upgrade \$http_upgrade;";
  312. echo ' proxy_set_header Connection upgrade;';
  313. echo ' }';
  314. echo '}'; } >> $git_ssb_nginx_site
  315. fi
  316. if [[ "$1" != "mesh" ]]; then
  317. nginx_ensite git_ssb
  318. fi
  319. }
  320. function mesh_install_dat {
  321. get_npm_arch
  322. mesh_setup_npm
  323. cat <<EOF > "$rootdir/usr/bin/install_dat"
  324. #!/bin/bash
  325. npm install --arch=$NPM_ARCH -g dat
  326. EOF
  327. chroot "$rootdir" /bin/chmod +x /usr/bin/install_dat
  328. chroot "$rootdir" /usr/bin/install_dat
  329. rm "$rootdir/usr/bin/install_dat"
  330. }
  331. function install_dat {
  332. npm install -g dat
  333. }
  334. function mesh_install_scuttlebot {
  335. #shellcheck disable=SC2153
  336. if [[ "$VARIANT" != "meshclient" && "$VARIANT" != "meshusb" ]]; then
  337. return
  338. fi
  339. SCUTTLEBOT_ONION_HOSTNAME=
  340. mesh_install_dat
  341. get_npm_arch
  342. mesh_setup_npm
  343. if [ ! -d "$rootdir/etc/scuttlebot" ]; then
  344. mkdir -p "$rootdir/etc/scuttlebot"
  345. fi
  346. # an unprivileged user to install and run as
  347. chroot "$rootdir" useradd -d /etc/scuttlebot/ scuttlebot
  348. chroot "$rootdir" chown -R scuttlebot:scuttlebot /etc/scuttlebot
  349. cat <<EOF > "$rootdir/usr/bin/install_scuttlebot"
  350. #!/bin/bash
  351. cd /etc/scuttlebot || exit 1
  352. if ! npm install --arch=$NPM_ARCH scuttlebot@${SCUTTLEBOT_VERSION}; then
  353. exit 2
  354. fi
  355. exit 0
  356. EOF
  357. chroot "$rootdir" /bin/chmod +x /usr/bin/install_scuttlebot
  358. chroot "$rootdir" sudo -u scuttlebot /usr/bin/install_scuttlebot
  359. rm "$rootdir/usr/bin/install_scuttlebot"
  360. if [ ! -f "$rootdir/etc/scuttlebot/node_modules/.bin/sbot" ]; then
  361. echo $'Scuttlebot was not installed'
  362. exit 528253
  363. fi
  364. cat <<EOF > "$rootdir/usr/bin/install_git_ssb"
  365. #!/bin/bash
  366. npm config set prefix '~/.npm-global'
  367. export PATH=~/.npm-global/bin:$PATH
  368. export NPM_CONFIG_PREFIX=~/.npm-global
  369. source ~/.profile
  370. if ! npm install --arch=$NPM_ARCH -g git-ssb; then
  371. exit 1
  372. fi
  373. if ! npm install --arch=$NPM_ARCH -g git-remote-ssb; then
  374. exit 2
  375. fi
  376. exit 0
  377. EOF
  378. chroot "$rootdir" /bin/chmod +x /usr/bin/install_git_ssb
  379. chroot "$rootdir" /usr/bin/install_git_ssb
  380. rm "$rootdir/usr/bin/install_git_ssb"
  381. # daemon
  382. { echo '[Unit]';
  383. echo 'Description=Scuttlebot (messaging system)';
  384. echo 'After=syslog.target';
  385. echo 'After=network.target';
  386. echo '';
  387. echo '[Service]';
  388. echo 'Type=simple';
  389. echo 'User=scuttlebot';
  390. echo 'Group=scuttlebot';
  391. echo "WorkingDirectory=/etc/scuttlebot";
  392. echo 'ExecStart=/etc/scuttlebot/node_modules/.bin/sbot server';
  393. echo 'Restart=always';
  394. echo 'Environment="USER=scuttlebot"';
  395. echo '';
  396. echo '[Install]';
  397. echo 'WantedBy=multi-user.target'; } > "$rootdir/etc/systemd/system/scuttlebot.service"
  398. scuttlebot_git_setup mesh
  399. git_ssb_script mesh
  400. }
  401. function install_scuttlebot {
  402. function_check install_nodejs
  403. install_nodejs scuttlebot
  404. if [ ! -d /etc/scuttlebot ]; then
  405. mkdir -p /etc/scuttlebot
  406. fi
  407. # an unprivileged user to install and run as
  408. useradd -d /etc/scuttlebot/ scuttlebot
  409. chown -R scuttlebot:scuttlebot /etc/scuttlebot
  410. cat <<EOF > /usr/bin/install_scuttlebot
  411. #!/bin/bash
  412. cd /etc/scuttlebot || exit 1
  413. if ! npm install scuttlebot@${SCUTTLEBOT_VERSION}; then
  414. exit 2
  415. fi
  416. exit 0
  417. EOF
  418. chmod +x /usr/bin/install_scuttlebot
  419. su -c '/usr/bin/install_scuttlebot' - scuttlebot
  420. rm /usr/bin/install_scuttlebot
  421. if [ ! -f /etc/scuttlebot/node_modules/.bin/sbot ]; then
  422. echo $'Scuttlebot was not installed'
  423. exit 528253
  424. fi
  425. install_dat
  426. npm install -g git-ssb
  427. npm install -g git-remote-ssb
  428. # daemon
  429. { echo '[Unit]';
  430. echo 'Description=Scuttlebot (messaging system)';
  431. echo 'After=syslog.target';
  432. echo 'After=network.target';
  433. echo '';
  434. echo '[Service]';
  435. echo 'Type=simple';
  436. echo 'User=scuttlebot';
  437. echo 'Group=scuttlebot';
  438. echo "WorkingDirectory=/etc/scuttlebot";
  439. echo 'ExecStart=/etc/scuttlebot/node_modules/.bin/sbot server';
  440. echo 'Restart=always';
  441. echo 'Environment="USER=scuttlebot"';
  442. echo '';
  443. echo '[Install]';
  444. echo 'WantedBy=multi-user.target'; } > /etc/systemd/system/scuttlebot.service
  445. chown -R scuttlebot:scuttlebot /etc/scuttlebot
  446. # files gw_name myhostname mdns4_minimal [NOTFOUND=return] dns
  447. sed -i "s|hosts:.*|hosts: files mdns4_minimal dns mdns4 mdns|g" /etc/nsswitch.conf
  448. # start the daemon
  449. systemctl enable scuttlebot.service
  450. systemctl daemon-reload
  451. systemctl start scuttlebot.service
  452. sleep 3
  453. if [ ! -d /etc/scuttlebot/.ssb ]; then
  454. echo $'Scuttlebot config not generated'
  455. exit 73528
  456. fi
  457. SCUTTLEBOT_ONION_HOSTNAME=$(add_onion_service scuttlebot 80 ${SCUTTLEBOT_ONION_PORT})
  458. if [[ "$ONION_ONLY" == 'no' ]]; then
  459. { echo '{';
  460. echo " \"host\": \"${DEFAULT_DOMAIN_NAME}\",";
  461. echo ' "tor-only": false,'; } > /etc/scuttlebot/.ssb/config
  462. else
  463. { echo '{';
  464. echo " \"host\": \"${SCUTTLEBOT_ONION_HOSTNAME}\",";
  465. echo ' "tor-only": true,'; } > /etc/scuttlebot/.ssb/config
  466. fi
  467. { echo " \"port\": ${SCUTTLEBOT_PORT},";
  468. echo ' "timeout": 30000,';
  469. echo ' "pub": true,';
  470. echo ' "local": true,';
  471. echo ' "friends": {';
  472. echo ' "dunbar": 150,';
  473. echo ' "hops": 3';
  474. echo ' },';
  475. echo ' "gossip": {';
  476. echo ' "connections": 2';
  477. echo ' },';
  478. echo ' "master": [],';
  479. echo ' "logging": {';
  480. echo ' "level": "error"';
  481. echo ' }';
  482. echo '}'; } >> /etc/scuttlebot/.ssb/config
  483. chown scuttlebot:scuttlebot /etc/scuttlebot/.ssb/config
  484. systemctl restart scuttlebot.service
  485. firewall_add scuttlebot ${SCUTTLEBOT_PORT}
  486. firewall_add git_ssb ${GIT_SSB_PORT}
  487. scuttlebot_git_setup
  488. git_ssb_script
  489. systemctl enable git_ssb.service
  490. systemctl daemon-reload
  491. systemctl start git_ssb.service
  492. function_check create_site_certificate
  493. create_site_certificate ${SCUTTLEBOT_DOMAIN_NAME} 'yes'
  494. systemctl restart nginx
  495. if ! grep -q "scuttlebot version:" "${COMPLETION_FILE}"; then
  496. echo "scuttlebot version:${SCUTTLEBOT_VERSION}" >> "${COMPLETION_FILE}"
  497. else
  498. sed -i "s|scuttlebot version.*|scuttlebot version:${SCUTTLEBOT_VERSION}|g" "${COMPLETION_FILE}"
  499. fi
  500. APP_INSTALLED=1
  501. }
  502. # NOTE: deliberately no exit 0