Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish domain changes with sbot #13

Merged
merged 11 commits into from Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -27,7 +27,7 @@ For more documentation about PeachPub, visit https://docs.peachcloud.org.
- Invite creation
- Update pub profile and description

**Shipped version:** 0.6.19~ynh7
**Shipped version:** 0.6.19~ynh8

**Demo:** https://demo.peachcloud.org

Expand Down
2 changes: 1 addition & 1 deletion README_fr.md
Expand Up @@ -27,7 +27,7 @@ For more documentation about PeachPub, visit https://docs.peachcloud.org.
- Invite creation
- Update pub profile and description

**Version incluse :** 0.6.19~ynh7
**Version incluse :** 0.6.19~ynh8

**Démo :** https://demo.peachcloud.org

Expand Down
2 changes: 1 addition & 1 deletion conf/amd64.src
@@ -1,5 +1,5 @@
SOURCE_URL=http://releases.peachcloud.org/yunohost/peachcloud_1.0_Linux_amd64.tar.gz
SOURCE_SUM=0b3fa67c27d8f7ec8f4d299e8e5fdb14f7a8f7fec71af6f28da5aa7e75203e2c
SOURCE_SUM=03fe3ef86769b7e3586559e69d2f3a0afc152761521094eb721ec37442e018ef
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
Expand Down
2 changes: 1 addition & 1 deletion conf/arm64.src
@@ -1,5 +1,5 @@
SOURCE_URL=http://releases.peachcloud.org/yunohost/peachcloud_1.0_Linux_aarch64.tar.gz
SOURCE_SUM=ef301f353881adbad76c90987a5b0355a031d9c8db1fb39ea287b770fdcd11b9
SOURCE_SUM=90c8a67c535ce094bc41d107ce0719515dd247035012dec3b71bc115ae12ff74
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
Expand Down
6 changes: 5 additions & 1 deletion conf/peach.yml
@@ -1 +1,5 @@
EXTERNAL_DOMAIN: __DOMAIN__
EXTERNAL_DOMAIN: __DOMAIN__
GO_SBOT_DATADIR: __DATADIR__/.ssb-go
PEACH_CONFIGDIR: __DATADIR__/config
GO_SBOT_SERVICE: __GO_SBOT_SERVICE__
PORT: __PORT__
2 changes: 1 addition & 1 deletion manifest.json
Expand Up @@ -5,7 +5,7 @@
"description": {
"en": "Secure Scuttlebutt pub with a web interface for pub management."
},
"version": "0.6.19~ynh7",
"version": "0.6.19~ynh8",
"url": "https://www.peachcloud.org",
"upstream": {
"license": "AGPL-3.0",
Expand Down
36 changes: 35 additions & 1 deletion scripts/_common.sh
Expand Up @@ -23,9 +23,43 @@ stop_systemd_services () {
# the first argument of this function $1, is $app
ynh_systemd_action --service_name=$app-go-sbot.service --action="stop" --log_path="/var/log/$app/$app-go-sbot.log"
ynh_systemd_action --service_name=$app-peach-web.service --action="stop" --log_path="/var/log/$app/$app-peach-web.log"

}

publish_address () {
# the first argument of this function $1, is $domain
# the second argument of this function $2, is $ssbport
# the third argument of this function $3, is the path to peach-config binary
# the following environmental variables must also be set: PEACH_CONFIG_PATH
host=$1
port=$2
peach_config=$3
echo $peach_config
sbot_is_running=0
num_attempts=0
while [ $sbot_is_running -eq 0 ] && [ $num_attempts -le 8 ]
do
whoami=$(PEACH_CONFIG_PATH=$PEACH_CONFIG_PATH $peach_config whoami) && return
if [ -z "$whoami" ]; then sbot_is_running=0; else sbot_is_running=1; fi
ynh_script_progression --message="whoami $whoami" --weight=1
if [ $sbot_is_running -eq 0 ]
then
sleep 2
num_attempts=$((num_attempts+1))
ynh_script_progression --message="trying again $num_attempts" --weight=1
fi
done
if [ $sbot_is_running -eq 1 ]
then
# now sbot is running, and we publish the address
PEACH_CONFIG_PATH=$PEACH_CONFIG_PATH $peach_config publish-address -a $host:$port
ynh_script_progression --message="successfully published $host:$port" --weight=1
else
# otherwise sbot failed to start, so lets exit with an error message
ynh_script_progression --message="Failed to publish address because sbot failed to start" --weight=1
exit 1
fi
}

#=================================================
# EXPERIMENTAL HELPERS
#=================================================
Expand Down
6 changes: 6 additions & 0 deletions scripts/change_url
Expand Up @@ -33,6 +33,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
peach_web_service=$(ynh_app_setting_get --app=$app --key=peach_web_service)
go_sbot_service=$(ynh_app_setting_get --app=$app --key=go_sbot_service)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
ssbport=$(ynh_app_setting_get --app=$app --key=ssbport)

#=================================================
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
Expand Down Expand Up @@ -130,6 +131,11 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service
start_systemd_services $app

# publish new domain with the sbot, once the services are running again
ynh_script_progression --message="Publishing new domain with sbot..." --weight=1
PEACH_CONFIG_PATH=$datadir/config/config.yml $final_path/peach-config wait-for-sbot
PEACH_CONFIG_PATH=$datadir/config/config.yml $final_path/peach-config publish-address -a $new_domain:$ssbport

#=================================================
# RELOAD NGINX
#=================================================
Expand Down
6 changes: 6 additions & 0 deletions scripts/install
Expand Up @@ -196,6 +196,12 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service
start_systemd_services $app

#=================================================
# CONFIGURE DOMAIN AFTER SBOT IS RUNNING
#=================================================
PEACH_CONFIG_PATH=$datadir/config/config.yml $final_path/peach-config wait-for-sbot
PEACH_CONFIG_PATH=$datadir/config/config.yml $final_path/peach-config publish-address -a $domain:$ssbport

#=================================================
# SETUP SSOWAT
#=================================================
Expand Down