From 5059727d5039efbf6bb8acb5e86d538cdf6572d6 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 11 Jul 2021 19:16:01 +0200 Subject: [PATCH] Few fixes --- manifest.json | 1 + scripts/install | 4 ++-- scripts/restore | 4 ++-- scripts/upgrade | 47 +++++++++++++++++++++++++++++++++++++++-------- 4 files changed, 44 insertions(+), 12 deletions(-) diff --git a/manifest.json b/manifest.json index d1a8e51..17fca68 100644 --- a/manifest.json +++ b/manifest.json @@ -6,6 +6,7 @@ "en": "A gemini server written in rust." }, "version": "0.4.4~ynh1", + "url": "https://codeberg.org/Valenoern/gemserv", "upstream": { "license": "MIT", "code": "https://codeberg.org/Valenoern/gemserv" diff --git a/scripts/install b/scripts/install index 1eeaa4f..1fc4136 100755 --- a/scripts/install +++ b/scripts/install @@ -146,7 +146,7 @@ ynh_use_logrotate #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" +yunohost service add $app --description="$app daemon" --log="/var/log/$app/$app.log" --needs_exposed_ports="1965" #================================================= # START SYSTEMD SERVICE @@ -154,7 +154,7 @@ yunohost service add $app --description="A short description of the app" --log=" ynh_script_progression --message="Starting a systemd service..." # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="start" --line_match="Started" --log_path="systemd" #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index 853f6bb..b4e97f6 100755 --- a/scripts/restore +++ b/scripts/restore @@ -88,14 +88,14 @@ systemctl enable $app.service --quiet #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" +yunohost service add $app --description="$app daemon" --log="/var/log/$app/$app.log" --needs_exposed_ports="1965" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="start" --line_match="Started" --log_path="systemd" #================================================= # RESTORE THE LOGROTATE CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index b3810d3..780b2d2 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -46,7 +46,7 @@ ynh_abort_if_errors #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="stop" --line_match="Stopped" --log_path="systemd" #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -61,6 +61,8 @@ ynh_script_progression --message="Making sure dedicated system user exists..." # Create a dedicated user (if not existing) ynh_system_user_create --username=$app --home_dir="$final_path" +usermod -a -G ssl-cert $app + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -70,7 +72,9 @@ then ynh_script_progression --message="Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" + ynh_setup_source --dest_dir="$final_path/build" + ynh_secure_remove --file="$final_path/live" + mkdir -p "$final_path/live" fi chmod 750 "$final_path" @@ -87,18 +91,45 @@ ynh_install_app_dependencies $pkg_dependencies #================================================= # SPECIFIC UPGRADE #================================================= -# ... +# MAKE INSTALL #================================================= +ynh_script_progression --message="Making install..." + +# Install rustup with the toolchain needed by vaultwarden +pushd "$final_path" + sudo -u "$app" RUSTUP_HOME="$final_path"/.rustup CARGO_HOME="$final_path"/.cargo bash -c 'curl -sSf -L https://static.rust-lang.org/rustup.sh | sh -s -- -y --default-toolchain nightly' +popd + +export PATH="$PATH:$final_path/.cargo/bin:$final_path/.local/bin:/usr/local/sbin" + +# Compile Gemserv +pushd "$final_path"/build + ynh_exec_warn_less sudo -u "$app" env PATH="$PATH" cargo build --release +popd + +# Install vaultwarden +cp -af "$final_path/build/target/release/gemserv" "$final_path/live/gemserv" + +# Remove build files and rustup +ynh_secure_remove --file="$final_path/build" +ynh_secure_remove --file="$final_path/.cargo" +ynh_secure_remove --file="$final_path/.rustup" #================================================= # UPDATE A CONFIG FILE #================================================= ynh_script_progression --message="Updating a configuration file..." -ynh_add_config --template="some_config_file" --destination="$final_path/some_config_file" +mkdir -p "/etc/$app/config.d/" -chmod 400 "$final_path/some_config_file" -chown $app:$app "$final_path/some_config_file" +chmod 750 "/etc/$app" +chmod -R o-rwx "/etc/$app" +chown -R $app:$app "/etc/$app" + +ynh_add_config --template="../conf/server.toml" --destination="/etc/$app/config.d/server.toml" + +chmod 400 "/etc/$app/config.d/server.toml" +chown $app:$app "/etc/$app/config.d/server.toml" #================================================= # SETUP SYSTEMD @@ -123,14 +154,14 @@ ynh_use_logrotate --non-append #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" +yunohost service add $app --description="$app daemon" --log="/var/log/$app/$app.log" --needs_exposed_ports="1965" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="start" --line_match="Started" --log_path="systemd" #================================================= # END OF SCRIPT