diff --git a/check_process b/check_process deleted file mode 100644 index e7510da..0000000 --- a/check_process +++ /dev/null @@ -1,26 +0,0 @@ -;; Test complet - ; Manifest - port="1965" - ; Checks - pkg_linter=1 - setup_sub_dir=0 - setup_root=0 - setup_nourl=1 - setup_private=0 - setup_public=0 - upgrade=1 - # 0.4.4~ynh1 - #upgrade=1 from_commit=3fcde5a7829938763b393ac1e878929bdc35297f - # 0.4.5~ynh1 - #upgrade=1 from_commit=d1e78f8cb47fc61dc3ede3e9cbb8445e364f0ab0 - # 0.6.3~ynh1 - upgrade=1 from_commit=884e8c80936563ee20896a1e2ea4ace85fc4c3a7 - # 0.6.6~ynh2 - upgrade=1 from_commit=f9e059a5ea4851aa51349319e8ed77f1e0676e46 - backup_restore=1 - multi_instance=0 - port_already_use=0 - change_url=0 -;;; Options -Email=yalh@yahoo.com -Notification=all diff --git a/conf/app.src b/conf/app.src deleted file mode 100644 index d21f30d..0000000 --- a/conf/app.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://git.sr.ht/~int80h/gemserv/archive/v0.6.6.tar.gz -SOURCE_SUM=a4423b91bff3e05708c296fe6135d00b7d09acc33b15c7d078a5c8753a84aa5a -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= -SOURCE_EXTRACT=true diff --git a/conf/systemd.service b/conf/systemd.service index 3f53475..b872cc5 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -6,13 +6,13 @@ After=network.target Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/ +WorkingDirectory=__INSTALL_DIR__/ ExecStartPre=-+/bin/bash -c 'chown -R __APP__:__APP__ /etc/__APP__/' ExecStartPre=-+/bin/bash -c 'chmod 600 /etc/__APP__/config.toml' ExecStartPre=-+/bin/bash -c 'chmod 600 /etc/__APP__/config.d/server.toml.head' ExecStartPre=-/bin/bash -c 'cp /etc/__APP__/config.d/server.toml.head /etc/__APP__/config.toml' ExecStartPre=-/bin/bash -c 'cat /etc/__APP__/config.d/*.toml >> /etc/__APP__/config.toml' -ExecStart=__FINALPATH__/live/__APP__ /etc/__APP__/config.toml +ExecStart=__INSTALL_DIR__/live/__APP__ /etc/__APP__/config.toml StandardOutput=append:/var/log/__APP__/__APP__.log StandardError=inherit Restart=always diff --git a/doc/DISCLAIMER.md b/doc/ADMIN.md similarity index 100% rename from doc/DISCLAIMER.md rename to doc/ADMIN.md diff --git a/doc/DISCLAIMER_fr.md b/doc/ADMIN_fr.md similarity index 100% rename from doc/DISCLAIMER_fr.md rename to doc/ADMIN_fr.md diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 573c122..0000000 --- a/manifest.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "Gemserv", - "id": "gemserv", - "packaging_format": 1, - "description": { - "en": "A gemini server written in rust." - }, - "version": "0.6.6~ynh6", - "url": "https://git.sr.ht/~int80h/gemserv/", - "upstream": { - "license": "MIT", - "code": "https://git.sr.ht/~int80h/gemserv" - }, - "license": "MIT", - "maintainer": { - "name": "yalh76" - }, - "requirements": { - "yunohost": ">= 4.3.0" - }, - "multi_instance": false, - "services": [ - "" - ], - "arguments": { - "install": [] - } -} diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..c7ce7b0 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,49 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json + +packaging_format = 2 + +id = "gemserv" +name = "Gemserv" +description.en = "A gemini server written in rust." + +version = "0.6.6~ynh6" + +maintainers = ["yalh76"] + +[upstream] +license = "MIT" +code = "https://git.sr.ht/~int80h/gemserv" +website = "https://git.sr.ht/~int80h/gemserv/" + +[integration] +yunohost = ">= 4.3.0" +architectures = "all" +multi_instance = false +ldap = "not_relevant" +sso = "not_relevant" +disk = "100M" +ram.build = "500M" +ram.runtime = "50M" + +[install] + +[resources] + [resources.sources.main] + url = "https://git.sr.ht/~int80h/gemserv/archive/v0.6.6.tar.gz" + sha256 = "a4423b91bff3e05708c296fe6135d00b7d09acc33b15c7d078a5c8753a84aa5a" + + # autoupdate.strategy = "latest_github_tag" + + [resources.system_user] + + [resources.ports] + main.default = 1965 + main.exposed = "TCP" + main.fixed = true + + [resources.install_dir] + + [resources.permissions] + + [resources.apt] + packages = ["pkg-config", "libssl-dev"] diff --git a/scripts/_common.sh b/scripts/_common.sh index e5212a8..944a65e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,9 +4,6 @@ # COMMON VARIABLES #================================================= -# dependencies used by the app -pkg_dependencies="pkg-config libssl-dev" - #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index 913e2c9..10889c7 100755 --- a/scripts/backup +++ b/scripts/backup @@ -10,25 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_print_info --message="Loading installation settings..." - -app=$YNH_APP_INSTANCE_NAME - -final_path=$(ynh_app_setting_get --app=$app --key=final_path) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= @@ -38,7 +19,7 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$final_path" +ynh_backup --src_path="$install_dir" #================================================= # SPECIFIC BACKUP diff --git a/scripts/install b/scripts/install index 2ec6724..73df670 100755 --- a/scripts/install +++ b/scripts/install @@ -9,76 +9,40 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# RETRIEVE ARGUMENTS FROM THE MANIFEST -#================================================= - -app=$YNH_APP_INSTANCE_NAME - -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= -ynh_script_progression --message="Validating installation parameters..." --weight=1 - -final_path=/opt/yunohost/$app -test ! -e "$final_path" || ynh_die --message="This path already contains a folder" - -#================================================= -# STANDARD MODIFICATIONS -#================================================= -# FIND AND OPEN A PORT -#================================================= -ynh_script_progression --message="Finding an available port..." --weight=1 - -# Find an available port -port=1965 -ynh_app_setting_set --app=$app --key=port --value=$port - -# Open the port -ynh_script_progression --message="Configuring firewall..." --weight=1 -ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port - -#================================================= -# INSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Installing dependencies..." --weight=1 - -ynh_install_app_dependencies $pkg_dependencies - #================================================= # CREATE DEDICATED USER #================================================= ynh_script_progression --message="Configuring system user..." --weight=1 -# Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" +usermod -a -G ssl-cert "$app" -usermod -a -G ssl-cert $app +#================================================= +# INSTALL RUST/CARGO +#================================================= +ynh_script_progression --message="Installing Rust and Cargo..." --weight=1 + +# Install rustup with the toolchain needed by Gemserv +pushd "$install_dir" + ynh_exec_warn_less ynh_exec_as "$app" \ + RUSTUP_HOME="$install_dir/.rustup" \ + CARGO_HOME="$install_dir/.cargo" \ + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \ + | ynh_exec_as "$app" sh -s -- -q -y +popd #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=1 -ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$final_path/build" +ynh_setup_source --dest_dir="$install_dir/build" -mkdir -p "$final_path/live" +mkdir -p "$install_dir/live" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R "$app:$app" "$install_dir" #================================================= # SPECIFIC SETUP @@ -87,25 +51,18 @@ chown -R $app:$app "$final_path" #================================================= ynh_script_progression --message="Building app..." --weight=1 -# Install rustup with the toolchain needed by Gemserv -pushd "$final_path" - ynh_exec_warn_less ynh_exec_as $app RUSTUP_HOME="$final_path"/.rustup CARGO_HOME="$final_path"/.cargo bash -c 'curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -q -y' -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 ynh_exec_as $app env PATH="$PATH" cargo build --release +pushd "$install_dir/build" + ynh_exec_warn_less ynh_exec_as "$app" bash -c "source $install_dir/.cargo/env; cargo build --release" popd # Install Gemserv -cp -af "$final_path/build/target/release/gemserv" "$final_path/live/gemserv" +cp -af "$install_dir/build/target/release/gemserv" "$install_dir/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" +ynh_secure_remove --file="$install_dir/build" +ynh_secure_remove --file="$install_dir/.cargo" +ynh_secure_remove --file="$install_dir/.rustup" #================================================= # ADD A CONFIGURATION @@ -116,45 +73,31 @@ mkdir -p "/etc/$app/config.d/" chmod 750 "/etc/$app" chmod -R o-rwx "/etc/$app" -chown -R $app:$app "/etc/$app" +chown -R "$app:$app" "/etc/$app" ynh_add_config --template="server.toml" --destination="/etc/$app/config.d/server.toml.head" chmod 600 "/etc/$app/config.d/server.toml.head" -chown $app:$app "/etc/$app/config.d/server.toml.head" +chown "$app:$app" "/etc/$app/config.d/server.toml.head" #================================================= -# SETUP SYSTEMD +# SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Configuring a systemd service..." --weight=1 +ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 # Create a dedicated systemd config ynh_add_systemd_config - -#================================================= -# GENERIC FINALIZATION -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Configuring log rotation..." --weight=1 +yunohost service add "$app" --description="$app daemon" --log="/var/log/$app/$app.log" --needs_exposed_ports="1965" # Use logrotate to manage application logfile(s) ynh_use_logrotate -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - -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..." --weight=1 -# Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --line_match="Started" --log_path="systemd" +ynh_systemd_action --service_name="$app" --action="start" --line_match="Started" --log_path="systemd" #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 491e867..e477c88 100755 --- a/scripts/remove +++ b/scripts/remove @@ -10,70 +10,21 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -port=$(ynh_app_setting_get --app=$app --key=port) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) - -#================================================= -# STANDARD REMOVE -#================================================= -# REMOVE SERVICE INTEGRATION IN YUNOHOST +# REMOVE SYSTEM CONFIGURATIONS #================================================= +ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 # Remove the service from the list of services known by YunoHost (added from `yunohost service add`) -if ynh_exec_warn_less yunohost service status $app >/dev/null -then - ynh_script_progression --message="Removing $app service integration..." --weight=1 - yunohost service remove $app +if ynh_exec_warn_less yunohost service status $app >/dev/null; then + yunohost service remove $app fi -#================================================= -# STOP AND REMOVE SERVICE -#================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1 - # Remove the dedicated systemd config ynh_remove_systemd_config -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Removing logrotate configuration..." --weight=1 - # Remove the app-specific logrotate config ynh_remove_logrotate -#================================================= -# REMOVE APP MAIN DIR -#================================================= -ynh_script_progression --message="Removing app main directory..." --weight=1 - -# Remove the app directory securely -ynh_secure_remove --file="$final_path" - -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." --weight=1 - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies - -#================================================= -# CLOSE A PORT -#================================================= - -if yunohost firewall list | grep -q "\- $port$" -then - ynh_script_progression --message="Closing port $port..." --weight=1 - ynh_exec_warn_less yunohost firewall disallow TCP $port -fi - #================================================= # SPECIFIC REMOVE #================================================= @@ -87,16 +38,6 @@ ynh_secure_remove --file="/etc/$app" # Remove the log files ynh_secure_remove --file="/var/log/$app" -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -ynh_script_progression --message="Removing the dedicated system user..." --weight=1 - -# Delete a system user -ynh_system_user_delete --username=$app - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 77ac4ed..f98ec5b 100755 --- a/scripts/restore +++ b/scripts/restore @@ -10,63 +10,27 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -final_path=$(ynh_app_setting_get --app=$app --key=final_path) - -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -ynh_script_progression --message="Validating restoration parameters..." --weight=1 - -test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path " - -#================================================= -# STANDARD RESTORATION STEPS -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # RESTORE THE APP MAIN DIR #================================================= ynh_script_progression --message="Restoring the app main directory..." --weight=1 -ynh_restore_file --origin_path="$final_path" +ynh_restore_file --origin_path="$install_dir" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R "$app:$app" "$install_dir" #================================================= -# SPECIFIC RESTORATION +# RESTORE SYSTEM CONFIGURATIONS #================================================= -# REINSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=1 +ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 -# Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies +ynh_restore_file --origin_path="/etc/systemd/system/$app.service" +systemctl enable "$app.service" --quiet +yunohost service add "$app" --description="$app daemon" --log="/var/log/$app/$app.log" --needs_exposed_ports="1965" + +ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # RESTORE VARIOUS FILES @@ -75,34 +39,12 @@ ynh_script_progression --message="Restoring various files..." --weight=1 ynh_restore_file --origin_path="/etc/$app/" -#================================================= -# RESTORE SYSTEMD -#================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 - -ynh_restore_file --origin_path="/etc/systemd/system/$app.service" -systemctl enable $app.service --quiet - -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 - -ynh_restore_file --origin_path="/etc/logrotate.d/$app" - -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - -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..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --line_match="Started" --log_path="systemd" +ynh_systemd_action --service_name="$app" --action="start" --line_match="Started" --log_path="systemd" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index c959a72..178f2b5 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,36 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -final_path=$(ynh_app_setting_get --app=$app --key=final_path) - -#================================================= -# CHECK VERSION -#================================================= -ynh_script_progression --message="Checking version..." --weight=1 - -upgrade_type=$(ynh_check_app_version_changed) - -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # Restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -54,47 +24,47 @@ ynh_systemd_action --service_name=$app --action="stop" --line_match="Stopped" -- ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 # Change to head file -if [ -f "/etc/$app/config.d/server.toml" ] -then - ynh_delete_file_checksum --file="/etc/$app/config.d/server.toml" - mv "/etc/$app/config.d/server.toml" "/etc/$app/config.d/server.toml.head" - ynh_store_file_checksum --file="/etc/$app/config.d/server.toml.head" +if [ -f "/etc/$app/config.d/server.toml" ]; then + ynh_delete_file_checksum --file="/etc/$app/config.d/server.toml" + mv "/etc/$app/config.d/server.toml" "/etc/$app/config.d/server.toml.head" + ynh_store_file_checksum --file="/etc/$app/config.d/server.toml.head" fi #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 +ynh_script_progression --message="Configuring system user..." --weight=1 -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" +usermod -a -G ssl-cert "$app" -usermod -a -G ssl-cert $app +#================================================= +# INSTALL RUST/CARGO +#================================================= +ynh_script_progression --message="Installing Rust and Cargo..." --weight=1 + +# Install rustup with the toolchain needed by Gemserv +pushd "$install_dir" + ynh_exec_warn_less ynh_exec_as "$app" \ + RUSTUP_HOME="$install_dir/.rustup" \ + CARGO_HOME="$install_dir/.cargo" \ + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \ + | ynh_exec_as "$app" sh -s -- -q -y +popd #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_script_progression --message="Upgrading source files..." --weight=1 -if [ "$upgrade_type" == "UPGRADE_APP" ] -then - ynh_script_progression --message="Upgrading source files..." --weight=1 +# Download, check integrity, uncompress and patch the source from app.src +ynh_setup_source --dest_dir="$install_dir/build" - # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path/build" - ynh_secure_remove --file="$final_path/live" - mkdir -p "$final_path/live" -fi +ynh_secure_remove --file="$install_dir/live" +mkdir -p "$install_dir/live" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" - -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=1 - -ynh_install_app_dependencies $pkg_dependencies +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R "$app:$app" "$install_dir" #================================================= # SPECIFIC UPGRADE @@ -103,28 +73,18 @@ ynh_install_app_dependencies $pkg_dependencies #================================================= ynh_script_progression --message="Building app..." --weight=1 -if [ "$upgrade_type" == "UPGRADE_APP" ] -then - # Install rustup with the toolchain needed by Gemserv - pushd "$final_path" - ynh_exec_warn_less ynh_exec_as $app RUSTUP_HOME="$final_path"/.rustup CARGO_HOME="$final_path"/.cargo bash -c 'curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -q -y' - popd +# Compile Gemserv +pushd "$install_dir/build" + ynh_exec_warn_less ynh_exec_as "$app" bash -c "source $install_dir/.cargo/env; cargo build --release" +popd - export PATH="$PATH:$final_path/.cargo/bin:$final_path/.local/bin:/usr/local/sbin" +# Install Gemserv +cp -af "$install_dir/build/target/release/gemserv" "$install_dir/live/gemserv" - # Compile Gemserv - pushd "$final_path"/build - ynh_exec_warn_less ynh_exec_as $app env PATH="$PATH" cargo build --release - popd - - # Install Gemserv - 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" -fi +# Remove build files and rustup +ynh_secure_remove --file="$install_dir/build" +ynh_secure_remove --file="$install_dir/.cargo" +ynh_secure_remove --file="$install_dir/.rustup" #================================================= # UPDATE A CONFIG FILE @@ -135,44 +95,31 @@ mkdir -p "/etc/$app/config.d/" chmod 750 "/etc/$app" chmod -R o-rwx "/etc/$app" -chown -R $app:$app "/etc/$app" +chown -R "$app:$app" "/etc/$app" ynh_add_config --template="server.toml" --destination="/etc/$app/config.d/server.toml.head" chmod 600 "/etc/$app/config.d/server.toml.head" -chown $app:$app "/etc/$app/config.d/server.toml.head" +chown "$app:$app" "/etc/$app/config.d/server.toml.head" #================================================= -# SETUP SYSTEMD +# REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 +ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 # Create a dedicated systemd config ynh_add_systemd_config - -#================================================= -# GENERIC FINALIZATION -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 +yunohost service add "$app" --description="$app daemon" --log="/var/log/$app/$app.log" --needs_exposed_ports="1965" # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - -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..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --line_match="Started" --log_path="systemd" +ynh_systemd_action --service_name="$app" --action="start" --line_match="Started" --log_path="systemd" #================================================= # END OF SCRIPT diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..a27ce41 --- /dev/null +++ b/tests.toml @@ -0,0 +1,14 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json + +test_format = 1.0 + +[default] + + # ------------------------------- + # Default args to use for install + # ------------------------------- + + # test_upgrade_from.3fcde5a7829938763b393ac1e878929bdc35297f.name = "0.4.4~ynh1" + # test_upgrade_from.d1e78f8cb47fc61dc3ede3e9cbb8445e364f0ab0.name = "0.4.5~ynh1" + test_upgrade_from.884e8c80936563ee20896a1e2ea4ace85fc4c3a7.name = "0.6.3~ynh1" + test_upgrade_from.f9e059a5ea4851aa51349319e8ed77f1e0676e46.name = "0.6.6~ynh2"