diff --git a/README.md b/README.md index a2e2a48..3d9b110 100644 --- a/README.md +++ b/README.md @@ -22,8 +22,6 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in - Only **root** (system user) can connect - Webmin will **update itself** when system updates are run. So no need to **run upgrade script** once installed. - Only **user** given permission at time of the installation can **access** the Webmin -- Installation can only be done on **root path**. e.g. webmin.domain.tld -- No **multi-instance** for webmin as it is a system integrated app ## Links diff --git a/issue_template.md b/issue_template.md new file mode 100644 index 0000000..81a3af9 --- /dev/null +++ b/issue_template.md @@ -0,0 +1,46 @@ +--- +name: Bug report +about: Create a report to help us debug, it would be nice to fill the template as much as you can to help us, help you and help us all. + +--- + +**How to post a meaningful bug report** +1. *Read this whole template first.* +2. *Determine if you are on the right place:* + - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change url...), you are on the right place!* + - *Otherwise, the issue may be due to WebMin itself. Refer to its documentation or repository for help.* + - *If you have a doubt, post here, we will figure it out together.* +3. *Delete the italic comments as you write over them below, and remove this guide.* +--- + +**Describe the bug** +*A clear and concise description of what the bug is.* + +**Versions** +- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...* +- YunoHost version: x.x.x +- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...* +- Are you in a special context or did you perform some particular tweaking on your YunoHost instance ?: *no / yes* + - If yes, please explain: +- Using, or trying to install package version/branch: +- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`* + +**To Reproduce** +*Steps to reproduce the behavior.* +- *If you performed a command from the CLI, the command itself is enough. For example:* + ```sh + sudo yunohost app install webmin + ``` +- *If you used the webadmin, please perform the equivalent command from the CLI first.* +- *If the error occurs in your browser, explain what you did:* + 1. *Go to '...'* + 2. *Click on '....'* + 3. *Scroll down to '....'* + 4. *See error* + +**Expected behavior** +*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.* + +**Logs** +*After a failed command, YunoHost makes the log available to you, but also to others, thanks to `yunohost log display [log name] --share`. The actual command, with the correct log name, is displayed at the end of the failed attempt in the CLI. Execute it and copy here the share link it outputs.* +*If applicable and useful, add screenshots to help explain your problem.* diff --git a/pull_request_template.md b/pull_request_template.md new file mode 100644 index 0000000..f5a0ec9 --- /dev/null +++ b/pull_request_template.md @@ -0,0 +1,18 @@ +## Problem +- *Description of why you made this PR* + +## Solution +- *And how do you fix that problem* + +## PR Status +- [ ] Code finished. +- [ ] Tested with Package_check. +- [ ] Fix or enhancement tested. +- [ ] Upgrade from last version tested. +- [ ] Can be reviewed and tested. + +## Package_check results +--- +*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results* + +[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/webmin_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/webmin_ynh%20PR-NUM-%20(USERNAME)/) diff --git a/scripts/backup b/scripts/backup index 47d3fd8..14274c6 100755 --- a/scripts/backup +++ b/scripts/backup @@ -42,6 +42,7 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # SPECIFIC BACKUP #================================================= + ynh_backup --src_path="/etc/webmin/miniserv.conf" #================================================= diff --git a/scripts/change_url b/scripts/change_url index 2f75b7a..9d168f1 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -23,13 +23,21 @@ app=$YNH_APP_INSTANCE_NAME #================================================= -# CHECK THE SYNTAX OF THE PATHS +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= +ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." -test -n "$old_path" || old_path="/" -test -n "$new_path" || new_path="/" -new_path=$(ynh_normalize_url_path $new_path) -old_path=$(ynh_normalize_url_path $old_path) +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. + ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" + + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED @@ -54,11 +62,12 @@ fi #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=1 -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 LSB" #================================================= # MODIFY URL IN NGINX CONF #================================================= +ynh_script_progression --message="Updating nginx web server configuration..." nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -66,7 +75,7 @@ nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf if [ $change_path -eq 1 ] then # Make a backup of the original nginx config file if modified - ynh_backup_if_checksum_is_different "$nginx_conf_path" + ynh_backup_if_checksum_is_different --file="$nginx_conf_path" # Set global variables for nginx helper domain="$old_domain" path_url="$new_path" @@ -78,12 +87,20 @@ fi if [ $change_domain -eq 1 ] then # Delete file checksum for the old conf file location - ynh_delete_file_checksum "$nginx_conf_path" + ynh_delete_file_checksum --file="$nginx_conf_path" mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf # Store file checksum for the new config file location - ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf" + ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." + +# Start a systemd service +ynh_systemd_action --service_name=$app --action="start" --line_match="Started LSB" + #================================================= # RELOAD NGINX #================================================= diff --git a/scripts/install b/scripts/install index 51b7f66..9cffd7d 100644 --- a/scripts/install +++ b/scripts/install @@ -58,22 +58,17 @@ ynh_script_progression --message="Configuring firewall..." --weight=1 # Find an available port port=$(ynh_find_port --port=10000) -# Open this port ynh_app_setting_set --app=$app --key=port --value=$port #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=1 +ynh_script_progression --message="Installing dependencies..." --weight=12 ynh_install_app_dependencies $pkg_dependencies -#================================================= -# DOWNLOAD, CHECK AND UNPACK SOURCE -#================================================= -ynh_script_progression --message="Setting up source files..." --weight=12 - -ynh_install_extra_app_dependencies --repo="deb http://download.webmin.com/download/repository sarge contrib" --package="webmin" --key="http://www.webmin.com/jcameron-key.asc" +# Install Webmin +ynh_install_extra_app_dependencies --repo="deb https://download.webmin.com/download/repository sarge contrib" --package="webmin" --key="https://download.webmin.com/jcameron-key.asc" #================================================= # NGINX CONFIGURATION @@ -83,20 +78,41 @@ ynh_script_progression --message="Configuring nginx web server..." --weight=11 # Create a dedicated nginx config ynh_add_nginx_config +#================================================= +# SPECIFIC SETUP #================================================= # MODIFY A CONFIG FILE #================================================= +ynh_script_progression --message="Modifying a config file..." --weight=1 -ynh_replace_string --match_string="port=10000" --replace_string="port=$port" --target_file="/etc/webmin/miniserv.conf" -ynh_replace_string --match_string="listen=10000" --replace_string="listen=$port" --target_file="/etc/webmin/miniserv.conf" +ynh_replace_string --match_string="port=10000" --replace_string="port=$port" --target_file="/etc/webmin/miniserv.conf" +ynh_replace_string --match_string="listen=10000" --replace_string="listen=$port" --target_file="/etc/webmin/miniserv.conf" #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= +ynh_script_progression --message="Storing the config file checksum..." --weight=1 # Calculate and store the config file checksum into the app settings ynh_store_file_checksum --file="/etc/webmin/miniserv.conf" +#================================================= +# GENERIC FINALIZATION +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 + +yunohost service add $app --description "Webmin Daemon" + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." + +# Start a systemd service +ynh_systemd_action --service_name=$app --action="start" --line_match="Started LSB" + #================================================= # SETUP SSOWAT #================================================= diff --git a/scripts/remove b/scripts/remove index 1717089..f313843 100644 --- a/scripts/remove +++ b/scripts/remove @@ -20,17 +20,31 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) port=$(ynh_app_setting_get --app=$app --key=port) #================================================= -# STOP WEBMIN +# STANDARD REMOVE +#================================================= +# REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= -ynh_script_progression --message="Stopping Webmin service..." --weight=1 -# Remove the dedicated Webmin -ynh_systemd_action --service_name=$app --action=stop +# 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..." + yunohost service remove $app +fi + +#================================================= +# STOP AND REMOVE SERVICE +#================================================= +ynh_script_progression --message="Stopping and removing the systemd service..." + +# Remove the dedicated systemd config +ynh_remove_systemd_config #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." --weight=3 +ynh_script_progression --message="Removing dependencies..." + # Remove metapackage and its dependencies ynh_remove_app_dependencies @@ -47,10 +61,16 @@ ynh_remove_nginx_config # SPECIFIC REMOVE #================================================= -ynh_remove_app_dependencies $app +if yunohost firewall list | grep -q "\- $port$" +then + ynh_script_progression --message="Closing port $port..." + ynh_exec_warn_less yunohost firewall disallow TCP $port +fi +#================================================= +# GENERIC FINALIZATION #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of WebMin completed" --last +ynh_script_progression --message="Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 1341c6e..97873f1 100755 --- a/scripts/restore +++ b/scripts/restore @@ -43,6 +43,7 @@ ynh_webpath_available --domain=$domain --path_url=$path_url \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Restoring the nginx configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" @@ -54,34 +55,37 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=10 # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies -#================================================= -# REINSTALL WEBMIN -#================================================= -ynh_script_progression --message="Setting up source files..." --weight=12 - -ynh_install_extra_app_dependencies --repo="deb http://download.webmin.com/download/repository sarge contrib" --package="webmin" --key="http://www.webmin.com/jcameron-key.asc" +# Install Webmin +ynh_install_extra_app_dependencies --repo="deb https://download.webmin.com/download/repository sarge contrib" --package="webmin" --key="https://download.webmin.com/jcameron-key.asc" #================================================= -# MODIFY A CONFIG FILE +# RESTORE VARIOUS FILES #================================================= +ynh_script_progression --message="Restoring the various files..." -ynh_replace_string --match_string="port=10000" --replace_string="port=$port" --target_file="/etc/webmin/miniserv.conf" -ynh_replace_string --match_string="listen=10000" --replace_string="listen=$port" --target_file="/etc/webmin/miniserv.conf" +ynh_restore_file --origin_path="/etc/webmin/miniserv.conf" #================================================= -# SETUP SSOWAT +# INTEGRATE SERVICE IN YUNOHOST #================================================= +ynh_script_progression --message="Integrating service in YunoHost..." -# Restrict access to admin only -yunohost app addaccess --users=$admin $app +yunohost service add $app --description "Webmin Daemon" #================================================= -# RELOAD NGINX AND START WEBMIN +# START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting webmin web server..." --weight=3 +ynh_script_progression --message="Starting a systemd service..." + +ynh_systemd_action --service_name=$app --action="start" --line_match="Started LSB" + +#================================================= +# GENERIC FINALIZATION +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading nginx web server..." -ynh_systemd_action --service_name=$app --action=enable -ynh_systemd_action --service_name=$app --action=start ynh_systemd_action --service_name=nginx --action=reload #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index b80e88f..031a7b2 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,16 +21,10 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) admin=$(ynh_app_setting_get --app=$app --key=admin) port=$(ynh_app_setting_get --app=$app --key=port) -#================================================= -# CHECK VERSION -#================================================= - -upgrade_type=$(ynh_check_app_version_changed) - #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up Webmin before upgrading (may take a while)..." --weight=3 +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -42,19 +36,28 @@ ynh_clean_setup () { ynh_abort_if_errors #================================================= -# NGINX CONFIGURATION +# CHECK THE PATH #================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=3 -# Create a dedicated NGINX config -ynh_add_nginx_config +# Normalize the URL path syntax +path_url=$(ynh_normalize_url_path --path_url=$path_url) +#================================================= +# STANDARD UPGRADE STEPS #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=2 +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 LSB" + +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Upgrading nginx web server configuration..." + +# Create a dedicated nginx config +ynh_add_nginx_config #================================================= # UPGRADE DEPENDENCIES @@ -63,42 +66,39 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=1 ynh_install_app_dependencies $pkg_dependencies +# Install Webmin +ynh_backup_if_checksum_is_different --file="/etc/webmin/miniserv.conf" +ynh_install_extra_app_dependencies --repo="deb https://download.webmin.com/download/repository sarge contrib" --package="webmin" --key="https://download.webmin.com/jcameron-key.asc" + #================================================= # INSTALL WEBMIN -#================================================= -ynh_script_progression --message="Installing dependencies..." --weight=30 - -ynh_install_extra_app_dependencies --repo="deb http://download.webmin.com/download/repository sarge contrib" --package="webmin" --key="http://www.webmin.com/jcameron-key.asc" - #================================================= # MODIFY A CONFIG FILE #================================================= - -### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. -ynh_backup_if_checksum_is_different "/etc/webmin/miniserv.conf" +ynh_script_progression --message="Modifying a config file..." ynh_replace_string --match_string="port=10000" --replace_string="port=$port" --target_file="/etc/webmin/miniserv.conf" ynh_replace_string --match_string="listen=10000" --replace_string="listen=$port" --target_file="/etc/webmin/miniserv.conf" # Recalculate and store the checksum of the file for the next upgrade. -ynh_store_file_checksum "/etc/webmin/miniserv.conf" +ynh_store_file_checksum --file="/etc/webmin/miniserv.conf" #================================================= -# SETUP SSOWAT +# GENERIC FINALIZATION #================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." -# Restrict access to admin only -# yunohost app addaccess --users=$admin $app +yunohost service add $app --description "Webmin Daemon" + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." + +ynh_systemd_action --service_name=$app --action="start" --line_match="Started LSB" -# #Make app public if necessary -# if [ $is_public -eq 1 ] -# then -# # unprotected_uris allows SSO credentials to be passed anyway -# ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" -# Create the admin permission if needed -if ! ynh_permission_exists --permission "admin"; then - ynh_permission_create --permission "admin" --url "/admin" --allowed $admin -fi #================================================= # START SYSTEMD SERVICE #=================================================