2021-09-08 10:52:58 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2021-09-10 14:41:29 +02:00
|
|
|
ynh_script_progression --message="Setting up source files..." --weight=1
|
2021-09-08 10:52:58 +02:00
|
|
|
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2024-01-06 00:11:26 +01:00
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
2021-09-08 10:52:58 +02:00
|
|
|
|
2024-01-06 00:11:26 +01:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2021-09-08 10:52:58 +02:00
|
|
|
|
2021-09-15 08:17:28 +02:00
|
|
|
#=================================================
|
|
|
|
# CREATE FIRST ADMIN USER
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Creating first ssbroom admin user" --weight=1
|
2022-07-02 19:06:02 +02:00
|
|
|
|
2021-09-16 17:18:00 +02:00
|
|
|
ynh_exec_as $app /usr/bin/expect<<EOF
|
|
|
|
set force_conservative 0 ;
|
|
|
|
set timeout -1
|
2024-01-06 00:11:26 +01:00
|
|
|
spawn sh -c "$install_dir/insert-user -repo $data_dir $ssb_admin_id"
|
2021-09-16 17:18:00 +02:00
|
|
|
match_max 100000
|
|
|
|
expect "*?assword: "
|
|
|
|
send -- "$password\r"
|
|
|
|
expect "*?assword: "
|
|
|
|
send -- "$password\r"
|
|
|
|
expect eof
|
|
|
|
EOF
|
2021-09-15 08:17:28 +02:00
|
|
|
|
2021-09-08 10:52:58 +02:00
|
|
|
#=================================================
|
2024-01-06 00:11:26 +01:00
|
|
|
# SYSTEM CONFIGURATION
|
2021-09-08 10:52:58 +02:00
|
|
|
#=================================================
|
2024-01-06 00:11:26 +01:00
|
|
|
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
|
|
|
|
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
2021-09-08 10:52:58 +02:00
|
|
|
|
|
|
|
# Create a dedicated systemd config
|
|
|
|
ynh_add_systemd_config
|
2024-01-06 00:11:26 +01:00
|
|
|
yunohost service add $app --description="Secure Scuttlebutt room server" --log="/var/log/$app/$app.log" --needs_exposed_ports $ssbport
|
2021-09-08 10:52:58 +02:00
|
|
|
|
|
|
|
# Use logrotate to manage application logfile(s)
|
|
|
|
ynh_use_logrotate
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2021-10-08 13:13:32 +02:00
|
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
2021-09-08 10:52:58 +02:00
|
|
|
|
|
|
|
# Start a systemd service
|
2022-07-02 19:06:02 +02:00
|
|
|
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="event=serving"
|
2021-09-08 10:52:58 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2021-10-08 13:13:32 +02:00
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|