Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
freedombone
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Context Sensitive Group
freedombone
Commits
f8fceee8
Commit
f8fceee8
authored
6 years ago
by
Bob Mottram
Browse files
Options
Downloads
Patches
Plain Diff
Tidy up scuttlebot and remove git-ssb
parent
2d4d8565
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/freedombone-app-scuttlebot
+33
-228
33 additions, 228 deletions
src/freedombone-app-scuttlebot
with
33 additions
and
228 deletions
src/freedombone-app-scuttlebot
+
33
−
228
View file @
f8fceee8
...
...
@@ -33,17 +33,12 @@ IN_DEFAULT_INSTALL=0
SHOW_ON_ABOUT
=
0
SHOW_CLEARNET_ADDRESS_ON_ABOUT
=
0
SCUTTLEBOT_DOMAIN_NAME
=
SCUTTLEBOT_CODE
=
SCUTTLEBOT_VERSION
=
'11.2.0'
SCUTTLEBOT_VERSION
=
'13.0.0'
SCUTTLEBOT_REPLICATE_NODES
=
5
SCUTTLEBOT_PORT
=
8010
SCUTTLEBOT_ONION_PORT
=
8623
GIT_SSB_PORT
=
7718
NGINX_GIT_SSB_PORT
=
7719
scuttlebot_variables
=(
MY_USERNAME
SCUTTLEBOT_DOMAIN_NAME
SCUTTLEBOT_CODE
DEFAULT_DOMAIN_NAME
SYSTEM_TYPE
)
...
...
@@ -130,9 +125,18 @@ function upgrade_scuttlebot {
return
fi
if
!
npm upgrade
-g
scuttlebot@
${
SCUTTLEBOT_VERSION
}
--save
;
then
return
fi
cat
<<
EOF
> /usr/bin/upgrade_scuttlebot
#!/bin/bash
cd /etc/scuttlebot || exit 1
if ! npm upgrade -g scuttlebot@
${
SCUTTLEBOT_VERSION
}
--save; then
exit 2
fi
exit 0
EOF
chmod
+x /usr/bin/upgrade_scuttlebot
su
-c
'/usr/bin/upgrade_scuttlebot'
- scuttlebot
rm
/usr/bin/upgrade_scuttlebot
sed
-i
"s|scuttlebot version.*|scuttlebot version:
${
SCUTTLEBOT_VERSION
}
|g"
"
${
COMPLETION_FILE
}
"
}
...
...
@@ -171,18 +175,9 @@ function restore_remote_scuttlebot {
function
remove_scuttlebot
{
firewall_remove
${
SCUTTLEBOT_PORT
}
firewall_remove
${
GIT_SSB_PORT
}
if
[
$SCUTTLEBOT_DOMAIN_NAME
]
;
then
nginx_dissite
${
SCUTTLEBOT_DOMAIN_NAME
}
rm
/etc/nginx/sites-available/
${
SCUTTLEBOT_DOMAIN_NAME
}
fi
systemctl stop git_ssb
systemctl stop scuttlebot
systemctl disable git_ssb
systemctl disable scuttlebot
rm
/etc/systemd/system/git_ssb.service
rm
/etc/systemd/system/scuttlebot.service
systemctl daemon-reload
...
...
@@ -191,174 +186,11 @@ function remove_scuttlebot {
if
[
-d
/etc/scuttlebot
]
;
then
rm
-rf
/etc/scuttlebot
fi
if
[
-f
/usr/bin/git-ssb-create
]
;
then
rm
/usr/bin/git-ssb-create
fi
remove_completion_param install_scuttlebot
sed
-i
'/scuttlebot /d'
"
$COMPLETION_FILE
"
}
function
git_ssb_script
{
if
[[
"
$1
"
==
"mesh"
]]
;
then
# shellcheck disable=SC2154
git_ssb_script_name
=
$rootdir
/usr/bin/git-ssb-create
git_ssb_daemon_filename
=
$rootdir
/etc/systemd/system/git_ssb.service
else
git_ssb_script_name
=
/usr/bin/git-ssb-create
git_ssb_daemon_filename
=
/etc/systemd/system/git_ssb.service
fi
{
echo
'#!/bin/bash'
;
echo
"reponame=
\"\$
1
\"
"
;
echo
''
;
echo
"if [[
\"\$
reponame
\"
!=
\"\"
]]; then"
;
echo
" mkdir
\$
reponame"
;
echo
" cd
\$
reponame"
;
echo
' git init'
;
echo
" git ssb create ssb
\$
reponame"
;
echo
' git push --tags ssb master'
;
echo
'fi'
;
echo
'exit 0'
;
}
>
$git_ssb_script_name
chmod
+x
$git_ssb_script_name
{
echo
'[Unit]'
;
echo
'Description=Git SSB (SSB git web interface)'
;
echo
'After=syslog.target'
;
echo
'After=network.target'
;
echo
'After=scuttlebot.target'
;
echo
''
;
echo
'[Service]'
;
echo
'Type=simple'
;
echo
'User=scuttlebot'
;
echo
'Group=scuttlebot'
;
echo
"WorkingDirectory=/etc/scuttlebot"
;
echo
"ExecStart=/usr/bin/git ssb web --public localhost:
$GIT_SSB_PORT
"
;
echo
'Restart=always'
;
echo
'Environment="USER=scuttlebot"'
;
echo
''
;
echo
'[Install]'
;
echo
'WantedBy=multi-user.target'
;
}
>
$git_ssb_daemon_filename
}
function
scuttlebot_git_setup
{
if
[[
"
$1
"
==
"mesh"
]]
;
then
if
[
!
-d
"
$rootdir
/root/.npm-global/lib/node_modules/git-ssb/node_modules/git-ssb-web/highlight"
]
;
then
mkdir
"
$rootdir
/root/.npm-global/lib/node_modules/git-ssb/node_modules/git-ssb-web/highlight"
fi
if
[
!
-f
"
$rootdir
/root/.npm-global/lib/node_modules/git-ssb/node_modules/highlight.js/styles/foundation.css"
]
;
then
echo
$'Could not find foundation.css'
exit
347687245
fi
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"
git_ssb_nginx_site
=
$rootdir
/etc/nginx/sites-available/git_ssb
{
echo
'server {'
;
echo
" listen
$NGINX_GIT_SSB_PORT
default_server;"
;
echo
" server_name P
${
PEER_ID
}
.local;"
;
echo
''
;
echo
' access_log /dev/null;'
;
echo
' error_log /dev/null;'
;
echo
''
;
echo
' add_header X-XSS-Protection "1; mode=block";'
;
echo
' add_header X-Content-Type-Options nosniff;'
;
echo
' add_header X-Frame-Options SAMEORIGIN;'
;
}
>
"
$git_ssb_nginx_site
"
else
if
[
!
$SCUTTLEBOT_DOMAIN_NAME
]
;
then
exit
7357225
fi
if
[
!
-d
/root/.npm-global/lib/node_modules/git-ssb/node_modules/git-ssb-web/highlight
]
;
then
mkdir
/root/.npm-global/lib/node_modules/git-ssb/node_modules/git-ssb-web/highlight
fi
if
[
!
-f
/root/.npm-global/lib/node_modules/git-ssb/node_modules/highlight.js/styles/foundation.css
]
;
then
echo
$'Could not find foundation.css'
exit
347687245
fi
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
git_ssb_nginx_site
=
/etc/nginx/sites-available/
${
SCUTTLEBOT_DOMAIN_NAME
}
function_check nginx_http_redirect
nginx_http_redirect
$SCUTTLEBOT_DOMAIN_NAME
"index index.html"
{
echo
'server {'
;
echo
' listen 443 ssl;'
;
echo
' #listen [::]:443 ssl;'
;
echo
" server_name
$SCUTTLEBOT_DOMAIN_NAME
;"
;
echo
''
;
}
>>
$git_ssb_nginx_site
function_check nginx_compress
nginx_compress
$SCUTTLEBOT_DOMAIN_NAME
echo
''
>>
"
$git_ssb_nginx_site
"
echo
' # Security'
>>
"
$git_ssb_nginx_site
"
function_check nginx_ssl
nginx_ssl
$SCUTTLEBOT_DOMAIN_NAME
function_check nginx_security_options
nginx_security_options
$SCUTTLEBOT_DOMAIN_NAME
fi
{
echo
''
;
echo
' root /root/.npm-global/lib/node_modules/git-ssb/node_modules/git-ssb-web;'
;
echo
''
;
echo
' location = / {'
;
echo
" proxy_pass http://localhost:
${
GIT_SSB_PORT
}
;"
;
echo
" proxy_set_header X-Real-IP
\$
remote_addr;"
;
echo
" proxy_set_header Host
\$
host;"
;
echo
" proxy_set_header X-Forwarded-For
\$
proxy_add_x_forwarded_for;"
;
echo
' proxy_http_version 1.1;'
;
echo
" proxy_set_header Upgrade
\$
http_upgrade;"
;
echo
' proxy_set_header Connection upgrade;'
;
echo
' }'
;
echo
'}'
;
}
>>
$git_ssb_nginx_site
if
[
"
$SCUTTLEBOT_ONION_HOSTNAME
"
]
;
then
{
echo
''
;
echo
'server {'
;
echo
" listen 127.0.0.1:
${
SCUTTLEBOT_ONION_PORT
}
default_server;"
;
echo
' port_in_redirect off;'
;
echo
" server_name
${
SCUTTLEBOT_ONION_HOSTNAME
}
;"
;
echo
''
;
echo
' access_log /dev/null;'
;
echo
' error_log /dev/null;'
;
echo
''
;
echo
' add_header X-XSS-Protection "1; mode=block";'
;
echo
' add_header X-Content-Type-Options nosniff;'
;
echo
' add_header X-Frame-Options SAMEORIGIN;'
;
echo
''
;
echo
' root /root/.npm-global/lib/node_modules/git-ssb/node_modules/git-ssb-web;'
;
echo
''
;
echo
' location = / {'
;
echo
" proxy_pass http://localhost:
${
GIT_SSB_PORT
}
;"
;
echo
" proxy_set_header X-Real-IP
\$
remote_addr;"
;
echo
" proxy_set_header Host
\$
host;"
;
echo
" proxy_set_header X-Forwarded-For
\$
proxy_add_x_forwarded_for;"
;
echo
' proxy_http_version 1.1;'
;
echo
" proxy_set_header Upgrade
\$
http_upgrade;"
;
echo
' proxy_set_header Connection upgrade;'
;
echo
' }'
;
echo
'}'
;
}
>>
$git_ssb_nginx_site
fi
if
[[
"
$1
"
!=
"mesh"
]]
;
then
nginx_ensite git_ssb
fi
}
function
mesh_install_dat
{
get_npm_arch
mesh_setup_npm
cat
<<
EOF
> "
$rootdir
/usr/bin/install_dat"
#!/bin/bash
npm install --arch=
$NPM_ARCH
-g dat
EOF
chroot
"
$rootdir
"
/bin/chmod +x /usr/bin/install_dat
chroot
"
$rootdir
"
/usr/bin/install_dat
rm
"
$rootdir
/usr/bin/install_dat"
}
function
install_dat
{
npm
install
-g
dat
}
function
mesh_install_scuttlebot
{
#shellcheck disable=SC2153
if
[[
"
$VARIANT
"
!=
"meshclient"
&&
"
$VARIANT
"
!=
"meshusb"
]]
;
then
...
...
@@ -367,8 +199,6 @@ function mesh_install_scuttlebot {
SCUTTLEBOT_ONION_HOSTNAME
=
mesh_install_dat
# shellcheck disable=SC2086
chroot
"
$rootdir
"
$INSTALL_PACKAGES
libsodium23
...
...
@@ -400,24 +230,6 @@ EOF
exit
528253
fi
cat
<<
EOF
> "
$rootdir
/usr/bin/install_git_ssb"
#!/bin/bash
npm config set prefix '~/.npm-global'
export PATH=~/.npm-global/bin:
$PATH
export NPM_CONFIG_PREFIX=~/.npm-global
source ~/.profile
if ! npm install --arch=
$NPM_ARCH
-g git-ssb; then
exit 1
fi
if ! npm install --arch=
$NPM_ARCH
-g git-remote-ssb; then
exit 2
fi
exit 0
EOF
chroot
"
$rootdir
"
/bin/chmod +x /usr/bin/install_git_ssb
chroot
"
$rootdir
"
/usr/bin/install_git_ssb
rm
"
$rootdir
/usr/bin/install_git_ssb"
# daemon
{
echo
'[Unit]'
;
echo
'Description=Scuttlebot (messaging system)'
;
...
...
@@ -435,9 +247,11 @@ EOF
echo
''
;
echo
'[Install]'
;
echo
'WantedBy=multi-user.target'
;
}
>
"
$rootdir
/etc/systemd/system/scuttlebot.service"
}
scuttlebot_git_setup mesh
git_ssb_script mesh
function
enable_mdns
{
# files gw_name myhostname mdns4_minimal [NOTFOUND=return] dns
sed
-i
"s|hosts:.*|hosts: files mdns4_minimal dns mdns4 mdns|g"
/etc/nsswitch.conf
}
function
install_scuttlebot
{
...
...
@@ -446,9 +260,10 @@ function install_scuttlebot {
$INSTALL_PACKAGES
libsodium23
if
[
!
-d
/etc/scuttlebot
]
;
then
mkdir
-p
/etc/scuttlebot
if
[
-d
/etc/scuttlebot
]
;
then
rm
-rf
/etc/scuttlebot
fi
mkdir
-p
/etc/scuttlebot
# an unprivileged user to install and run as
useradd
-d
/etc/scuttlebot/ scuttlebot
...
...
@@ -471,10 +286,6 @@ EOF
exit
528253
fi
install_dat
npm
install
-g
git-ssb
npm
install
-g
git-remote-ssb
# daemon
{
echo
'[Unit]'
;
echo
'Description=Scuttlebot (messaging system)'
;
...
...
@@ -495,15 +306,22 @@ EOF
chown
-R
scuttlebot:scuttlebot /etc/scuttlebot
# files gw_name myhostname mdns4_minimal [NOTFOUND=return] dns
sed
-i
"s|hosts:.*|hosts: files mdns4_minimal dns mdns4 mdns|g"
/etc/nsswitch.conf
enable_mdns
# start the daemon
systemctl
enable
scuttlebot.service
systemctl daemon-reload
systemctl start scuttlebot.service
sleep
3
# wait for the config to be created
scuttlebot_ctr
=
10
until
[
$scuttlebot_ctr
-gt
0
]
;
do
if
[
-d
/etc/scuttlebot/.ssb
]
;
then
break
fi
sleep
3
scuttlebot_ctr
=
$((
scuttlebot_ctr-1
))
done
if
[
!
-d
/etc/scuttlebot/.ssb
]
;
then
echo
$'Scuttlebot config not generated'
...
...
@@ -527,8 +345,8 @@ EOF
echo
' "pub": true,'
;
echo
' "local": true,'
;
echo
' "friends": {'
;
echo
'
"dunbar":
150,'
;
echo
' "hops":
3
'
;
echo
"
\
"
dunbar
\
"
:
${
SCUTTLEBOT_REPLICATE_NODES
}
,"
;
echo
' "hops":
1
'
;
echo
' },'
;
echo
' "gossip": {'
;
echo
' "connections": 2'
;
...
...
@@ -542,19 +360,6 @@ EOF
systemctl restart scuttlebot.service
firewall_add scuttlebot
${
SCUTTLEBOT_PORT
}
firewall_add git_ssb
${
GIT_SSB_PORT
}
scuttlebot_git_setup
git_ssb_script
systemctl
enable
git_ssb.service
systemctl daemon-reload
systemctl start git_ssb.service
function_check create_site_certificate
create_site_certificate
${
SCUTTLEBOT_DOMAIN_NAME
}
'yes'
systemctl restart nginx
if
!
grep
-q
"scuttlebot version:"
"
${
COMPLETION_FILE
}
"
;
then
echo
"scuttlebot version:
${
SCUTTLEBOT_VERSION
}
"
>>
"
${
COMPLETION_FILE
}
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment