From 1edd5bbe593f60e08ea263ab73dda06f6eef6807 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 6 Dec 2021 22:54:30 +0100 Subject: [PATCH 01/14] Fix --- conf/cockpit.conf | 8 ++++++++ manifest.json | 12 +++++++----- scripts/install | 10 ++++++++-- 3 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 conf/cockpit.conf diff --git a/conf/cockpit.conf b/conf/cockpit.conf new file mode 100644 index 0000000..4adb59a --- /dev/null +++ b/conf/cockpit.conf @@ -0,0 +1,8 @@ +[WebService] +Origins = https://__DOMAIN__ +https://127.0.0.1:9090 + +[WebService] +ProtocolHeader = X-Forwarded-Proto + +UrlRoot = __PATH__/ \ No newline at end of file diff --git a/manifest.json b/manifest.json index e9dbce2..ab8b47e 100644 --- a/manifest.json +++ b/manifest.json @@ -11,9 +11,7 @@ "upstream": { "license": "LGPL-2.1-only", "website": "https://cockpit-project.org/", - "demo": "https://demo.example.com", - "admindoc": "https://cockpit-project.org/documentation.html", - "code": "https://some.forge.com/example/example" + "admindoc": "https://cockpit-project.org/documentation.html" }, "license": "LGPL-2.1-only", "maintainer": { @@ -35,8 +33,12 @@ { "name": "path", "type": "path", - "example": "/cockpit", - "default": "/cockpit" + "help": { + "en": "/cockpit/ and /cockpit+ are reserved and should not be used.", + "fr": "/cockpit/ et /cockpit+ sont réservés et ne doivent pas être utilisés." + }, + "example": "/monitor", + "default": "/monitor" }, { "name": "is_public", diff --git a/scripts/install b/scripts/install index 38a1043..9e75e99 100644 --- a/scripts/install +++ b/scripts/install @@ -68,6 +68,13 @@ ynh_script_progression --message="Installing dependencies..." --weight=20 ynh_install_app_dependencies $pkg_dependencies +#================================================= +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message="Adding a configuration file..." --weight=1 + +ynh_add_config --template="../conf/cockpite.conf" --destination="/etc/cockpit/cockpit.conf" + #================================================= # NGINX CONFIGURATION #================================================= @@ -82,8 +89,7 @@ ynh_add_nginx_config ynh_script_progression --message="Starting a systemd service..." --weight=2 # Reload services -systemctl start $app -systemctl enable $app --quiet +systemctl enable cockpit.socket --quiet #================================================= # SETUP SSOWAT From 3e333d1c4ad2c106cbfdae2570d5d5c71391d8b7 Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Mon, 6 Dec 2021 21:54:37 +0000 Subject: [PATCH 02/14] Auto-update README --- README.md | 3 +-- README_fr.md | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5c34233..5d95937 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Cockpit is a web-based graphical interface for servers, intended for everyone. **Shipped version:** 257~ynh1 -**Demo:** https://demo.example.com + ## Screenshots @@ -29,7 +29,6 @@ Cockpit is a web-based graphical interface for servers, intended for everyone. * Official app website: https://cockpit-project.org/ * Official admin documentation: https://cockpit-project.org/documentation.html -* Upstream app code repository: https://some.forge.com/example/example * YunoHost documentation for this app: https://yunohost.org/app_cockpit * Report a bug: https://github.com/YunoHost-Apps/cockpit_ynh/issues diff --git a/README_fr.md b/README_fr.md index 1d91fce..b55e13d 100644 --- a/README_fr.md +++ b/README_fr.md @@ -15,7 +15,7 @@ Cockpit is a web-based graphical interface for servers, intended for everyone. **Version incluse :** 257~ynh1 -**Démo :** https://demo.example.com + ## Captures d'écran @@ -25,7 +25,6 @@ Cockpit is a web-based graphical interface for servers, intended for everyone. * Site officiel de l'app : https://cockpit-project.org/ * Documentation officielle de l'admin : https://cockpit-project.org/documentation.html -* Dépôt de code officiel de l'app : https://some.forge.com/example/example * Documentation YunoHost pour cette app : https://yunohost.org/app_cockpit * Signaler un bug : https://github.com/YunoHost-Apps/cockpit_ynh/issues From 86a3973511709634ac8b67162c72ac537d1ed72a Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 6 Dec 2021 22:57:44 +0100 Subject: [PATCH 03/14] Update install --- scripts/install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 9e75e99..7a7516c 100644 --- a/scripts/install +++ b/scripts/install @@ -66,14 +66,14 @@ ynh_app_setting_set --app=$app --key=port --value=$port #================================================= ynh_script_progression --message="Installing dependencies..." --weight=20 -ynh_install_app_dependencies $pkg_dependencies +ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies #================================================= # ADD A CONFIGURATION #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=1 -ynh_add_config --template="../conf/cockpite.conf" --destination="/etc/cockpit/cockpit.conf" +ynh_add_config --template="../conf/cockpit.conf" --destination="/etc/cockpit/cockpit.conf" #================================================= # NGINX CONFIGURATION From 43b1e23c12a2ff3fe6ed33d31d54084eace5a01a Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 6 Dec 2021 23:01:56 +0100 Subject: [PATCH 04/14] Update install --- scripts/install | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/scripts/install b/scripts/install index 7a7516c..9ed57aa 100644 --- a/scripts/install +++ b/scripts/install @@ -89,18 +89,25 @@ ynh_add_nginx_config ynh_script_progression --message="Starting a systemd service..." --weight=2 # Reload services -systemctl enable cockpit.socket --quiet +#systemctl enable cockpit.socket --quiet +ynh_systemd_action --service_name=cockpit.socket --action=start + +#================================================= +# ADVERTISE SERVICE IN ADMIN PANEL +#================================================= + +yunohost service add cockpit.socket --description="Monitor" #--log="/var/log/syslog" #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." --weight=1 +# ynh_script_progression --message="Configuring SSOwat..." --weight=1 -# Make app public if necessary or protect it -if [ $is_public -eq 1 ] -then - ynh_permission_update --permission "main" --add "visitors" -fi +# # Make app public if necessary or protect it +# if [ $is_public -eq 1 ] +# then +# ynh_permission_update --permission "main" --add "visitors" +# fi #================================================= # RELOAD NGINX From dff622dcdac6adca3a5a17329a4730c7dff9d24a Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 6 Dec 2021 23:06:28 +0100 Subject: [PATCH 05/14] Update install --- scripts/install | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 9ed57aa..9101304 100644 --- a/scripts/install +++ b/scripts/install @@ -90,7 +90,7 @@ ynh_script_progression --message="Starting a systemd service..." --weight=2 # Reload services #systemctl enable cockpit.socket --quiet -ynh_systemd_action --service_name=cockpit.socket --action=start +#ynh_systemd_action --service_name=cockpit.socket --action=start #================================================= # ADVERTISE SERVICE IN ADMIN PANEL @@ -98,6 +98,8 @@ ynh_systemd_action --service_name=cockpit.socket --action=start yunohost service add cockpit.socket --description="Monitor" #--log="/var/log/syslog" +ynh_systemd_action --service_name=cockpit.socket --action="start" --log_path="/var/log/$app/$app.log" + #================================================= # SETUP SSOWAT #================================================= From 9ac97734ed74715e54085b5b7e8e25b9e26230eb Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 6 Dec 2021 23:12:58 +0100 Subject: [PATCH 06/14] Fix --- conf/nginx.conf | 2 +- manifest.json | 5 ----- scripts/install | 28 +++++++--------------------- scripts/remove | 10 +--------- 4 files changed, 9 insertions(+), 36 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 9e0344f..d386d46 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,7 +1,7 @@ #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location ^~ __PATH__/ { - proxy_pass http://127.0.0.1:__PORT__; + proxy_pass http://127.0.0.1:__PORT__/; proxy_http_version 1.1; proxy_buffering off; proxy_set_header X-Real-IP $remote_addr; diff --git a/manifest.json b/manifest.json index ab8b47e..5f88acf 100644 --- a/manifest.json +++ b/manifest.json @@ -39,11 +39,6 @@ }, "example": "/monitor", "default": "/monitor" - }, - { - "name": "is_public", - "type": "boolean", - "default": true } ] } diff --git a/scripts/install b/scripts/install index 9101304..87b5f56 100644 --- a/scripts/install +++ b/scripts/install @@ -83,34 +83,20 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=2 # Create a dedicated NGINX config ynh_add_nginx_config +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 + +yunohost service add cockpit.socket --description="Monitor" --log="/var/log/$app/$app.log" + #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=2 -# Reload services -#systemctl enable cockpit.socket --quiet -#ynh_systemd_action --service_name=cockpit.socket --action=start - -#================================================= -# ADVERTISE SERVICE IN ADMIN PANEL -#================================================= - -yunohost service add cockpit.socket --description="Monitor" #--log="/var/log/syslog" - ynh_systemd_action --service_name=cockpit.socket --action="start" --log_path="/var/log/$app/$app.log" -#================================================= -# SETUP SSOWAT -#================================================= -# ynh_script_progression --message="Configuring SSOwat..." --weight=1 - -# # Make app public if necessary or protect it -# if [ $is_public -eq 1 ] -# then -# ynh_permission_update --permission "main" --add "visitors" -# fi - #================================================= # RELOAD NGINX #================================================= diff --git a/scripts/remove b/scripts/remove index a327b7a..09dbbb7 100644 --- a/scripts/remove +++ b/scripts/remove @@ -30,7 +30,7 @@ final_path=$(ynh_app_setting_get $app final_path) if ynh_exec_warn_less yunohost service status $app >/dev/null then ynh_script_progression --message="Removing $app service..." --weight=1 - yunohost service remove $app + yunohost service remove cockpit.socket fi #================================================= @@ -49,14 +49,6 @@ ynh_script_progression --message="Removing dependencies..." --weight=1 # Remove metapackage and its dependencies ynh_remove_app_dependencies -#================================================= -# REMOVE APP MAIN DIR -#================================================= -# ynh_print_info "Removing app main directory" - -# # Remove the app directory securely -# ynh_secure_remove "$final_path" - #================================================= # REMOVE NGINX CONFIGURATION #================================================= From 3cbb950504fac3afeda7d34c472fea020a9fad72 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 6 Dec 2021 23:14:43 +0100 Subject: [PATCH 07/14] Update install --- scripts/install | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/scripts/install b/scripts/install index 87b5f56..f9a3e89 100644 --- a/scripts/install +++ b/scripts/install @@ -22,25 +22,16 @@ ynh_abort_if_errors # Retrieve arguments domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH -is_public=$YNH_APP_ARG_IS_PUBLIC app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -# ynh_script_progression --message="Validating installation parameters..." --weight=1 +ynh_script_progression --message="Validating installation parameters..." --weight=1 -# final_path=/var/www/$app -# test ! -e "$final_path" || ynh_die "This path already contains a folder" - -# # Normalize the url path syntax -# path_url=$(ynh_normalize_url_path $path_url) - -# # Check web path availability -# ynh_webpath_available $domain $path_url -# # Register (book) web path -# ynh_webpath_register $app $domain $path_url +# Register (book) web path +ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST From c5402814aad83e63e9a46662ac10e6aedb69bfdf Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 6 Dec 2021 23:17:42 +0100 Subject: [PATCH 08/14] Update install --- scripts/install | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index f9a3e89..ae0e14e 100644 --- a/scripts/install +++ b/scripts/install @@ -79,15 +79,16 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add cockpit.socket --description="Monitor" --log="/var/log/$app/$app.log" +#yunohost service add cockpit.socket --description="Monitor" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=2 -ynh_systemd_action --service_name=cockpit.socket --action="start" --log_path="/var/log/$app/$app.log" - +#ynh_systemd_action --service_name=cockpit.socket --action="start" --log_path="/var/log/$app/$app.log" +systemctl enable cockpit.socket +systemctl start cockpit.socket #================================================= # RELOAD NGINX #================================================= From 517e5996aca6551f7b014331022a92fe8802edf4 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 13 Mar 2022 21:51:45 +0100 Subject: [PATCH 09/14] Apply example_ynh --- .github/ISSUE_TEMPLATE.md | 55 ++++++++++++ .github/PULL_REQUEST_TEMPLATE.md | 16 ++++ check_process | 5 +- conf/cockpit.conf | 4 - doc/DESCRIPTION.md | 3 +- manifest.json | 6 +- scripts/backup | 9 +- scripts/change_url | 139 +++++++++++++++++++++++++++++++ scripts/install | 37 ++++---- scripts/remove | 40 +++++---- scripts/restore | 41 ++++----- scripts/upgrade | 47 ++++++++--- 12 files changed, 320 insertions(+), 82 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 scripts/change_url diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..2729a6b --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,55 @@ +--- +name: Bug report +about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently. + +--- + +**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 the app itself. Refer to its documentation or repository for help.* + - *When in doubt, post here and 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.* + +### Context + +- 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`* + +### Steps to reproduce + +- *If you performed a command from the CLI, the command itself is enough. For example:* + ```sh + sudo yunohost app install the_app + ``` +- *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 + +*When an operation fails, YunoHost provides a simple way to share the logs.* +- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.* +- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.* + +*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)* + +*If applicable and useful, add screenshots to help explain your problem.* diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..ef70e18 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,16 @@ +## Problem + +- *Description of why you made this PR* + +## Solution + +- *And how do you fix that problem* + +## PR Status + +- [ ] Code finished and ready to be reviewed/tested +- [ ] The fix/enhancement were manually tested (if applicable) + +## Automatic tests + +Automatic tests can be triggered on https://ci-apps-dev.yunohost.org/ *after creating the PR*, by commenting "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization) diff --git a/check_process b/check_process index 057ec49..6b536e2 100644 --- a/check_process +++ b/check_process @@ -1,16 +1,13 @@ ;; Test complet ; Manifest domain="domain.tld" - path="/" - is_public=1 - port="9090" ; Checks pkg_linter=1 setup_sub_dir=0 setup_root=1 setup_nourl=0 setup_private=0 - setup_public=1 + setup_public=0 upgrade=1 backup_restore=1 multi_instance=0 diff --git a/conf/cockpit.conf b/conf/cockpit.conf index 4adb59a..363e627 100644 --- a/conf/cockpit.conf +++ b/conf/cockpit.conf @@ -1,7 +1,3 @@ -[WebService] -Origins = https://__DOMAIN__ -https://127.0.0.1:9090 - [WebService] ProtocolHeader = X-Forwarded-Proto diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md index d33d446..39c4d8d 100644 --- a/doc/DESCRIPTION.md +++ b/doc/DESCRIPTION.md @@ -1 +1,2 @@ -Cockpit is a web-based graphical interface for servers, intended for everyone. \ No newline at end of file +Cockpit is a web-based graphical interface for servers, intended for everyone. + diff --git a/manifest.json b/manifest.json index 5f88acf..3fbccec 100644 --- a/manifest.json +++ b/manifest.json @@ -11,7 +11,8 @@ "upstream": { "license": "LGPL-2.1-only", "website": "https://cockpit-project.org/", - "admindoc": "https://cockpit-project.org/documentation.html" + "admindoc": "https://cockpit-project.org/documentation.html", + "code": "https://github.com/cockpit-project/cockpit" }, "license": "LGPL-2.1-only", "maintainer": { @@ -26,7 +27,8 @@ "nginx" ], "arguments": { - "install": [{ + "install": [ + { "name": "domain", "type": "domain" }, diff --git a/scripts/backup b/scripts/backup index b8c5fad..5bbfcd7 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -14,7 +15,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - ynh_clean_check_starting + true } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -43,13 +44,13 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # SPECIFIC BACKUP #================================================= -# BACKUP SYSTEMD +# BACKUP VARIOUS FILES #================================================= -ynh_backup --src_path="/etc/systemd/system/$app.service" +ynh_backup --src_path="/etc/cockpit/cockpit.conf" #================================================= # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for cockpit. (YunoHost will then actually copy those files to the archive)." +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url new file mode 100644 index 0000000..139a41c --- /dev/null +++ b/scripts/change_url @@ -0,0 +1,139 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +old_domain=$YNH_APP_OLD_DOMAIN +old_path=$YNH_APP_OLD_PATH + +new_domain=$YNH_APP_NEW_DOMAIN +new_path=$YNH_APP_NEW_PATH + +app=$YNH_APP_INSTANCE_NAME + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." + +# Needed for helper "ynh_add_nginx_config" +final_path=$(ynh_app_setting_get --app=$app --key=final_path) + +# Add settings here as needed by your application +#db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#db_user=$db_name +#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) + +#================================================= +# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + ynh_clean_check_starting + # 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 +#================================================= + +change_domain=0 +if [ "$old_domain" != "$new_domain" ] +then + change_domain=1 +fi + +change_path=0 +if [ "$old_path" != "$new_path" ] +then + change_path=1 +fi + +#================================================= +# STANDARD MODIFICATIONS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." + +ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" + +#================================================= +# 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 + +# Change the path in the NGINX config file +if [ $change_path -eq 1 ] +then + # Make a backup of the original NGINX config file if modified + ynh_backup_if_checksum_is_different --file="$nginx_conf_path" + # Set global variables for NGINX helper + domain="$old_domain" + path_url="$new_path" + # Create a dedicated NGINX config + ynh_add_nginx_config +fi + +# Change the domain for NGINX +if [ $change_domain -eq 1 ] +then + # Delete file checksum for the old conf file location + 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 --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" +fi + +#================================================= +# SPECIFIC MODIFICATIONS +#================================================= +# UPDATE A CONFIG FILE +#================================================= +ynh_script_progression --message="Updating a configuration file..." + +ynh_add_config --template="../conf/cockpit.conf" --destination="/etc/cockpit/cockpit.conf" + +#================================================= +# GENERIC FINALISATION +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." + +# Start a systemd service +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started" + +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading NGINX web server..." + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index ae0e14e..437ee60 100644 --- a/scripts/install +++ b/scripts/install @@ -19,7 +19,6 @@ ynh_abort_if_errors # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -# Retrieve arguments domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH @@ -46,10 +45,10 @@ ynh_app_setting_set --app=$app --key=path --value=$path_url #================================================= # FIND AND OPEN A PORT #================================================= -ynh_script_progression --message="Configuring firewall..." --weight=2 +ynh_script_progression --message="Finding an available port..." --weight=2 # Find an available port -port=$(ynh_find_port --port=9090) +port=$(ynh_find_port --port=8095) ynh_app_setting_set --app=$app --key=port --value=$port #================================================= @@ -59,13 +58,6 @@ ynh_script_progression --message="Installing dependencies..." --weight=20 ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies -#================================================= -# ADD A CONFIGURATION -#================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=1 - -ynh_add_config --template="../conf/cockpit.conf" --destination="/etc/cockpit/cockpit.conf" - #================================================= # NGINX CONFIGURATION #================================================= @@ -74,21 +66,38 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=2 # Create a dedicated NGINX config ynh_add_nginx_config +#================================================= +# SPECIFIC SETUP +#================================================= +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message="Adding a configuration file..." --weight=1 + +ynh_replace_string --match_string="ListenStream=.*" --replace_string="ListenStream=$port" --target_file="/lib/systemd/system/cockpit.socket" +systemctl daemon-reload +systemctl restart $app.socket + +ynh_add_config --template="../conf/cockpit.conf" --destination="/etc/cockpit/cockpit.conf" + +chmod 440 "/etc/cockpit/cockpit.conf" +chown root:$app-ws "/etc/cockpit/cockpit.conf" + +#================================================= +# GENERIC FINALIZATION #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -#yunohost service add cockpit.socket --description="Monitor" --log="/var/log/$app/$app.log" +yunohost service add $app #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=2 -#ynh_systemd_action --service_name=cockpit.socket --action="start" --log_path="/var/log/$app/$app.log" -systemctl enable cockpit.socket -systemctl start cockpit.socket +ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd" --line_match="Started" + #================================================= # RELOAD NGINX #================================================= diff --git a/scripts/remove b/scripts/remove index 09dbbb7..028e55b 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,13 +12,13 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -port=$(ynh_app_setting_get $app port) -final_path=$(ynh_app_setting_get $app final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) +port=$(ynh_app_setting_get --app=$app --key=port) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # STANDARD REMOVE @@ -26,11 +26,11 @@ final_path=$(ynh_app_setting_get $app final_path) # REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= -# Remove the service from the list of services known by Yunohost (added from `yunohost service add`) +# 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..." --weight=1 - yunohost service remove cockpit.socket + yunohost service remove $app fi #================================================= @@ -39,15 +39,7 @@ fi ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1 # Remove the dedicated systemd config -ynh_remove_systemd_config - -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." --weight=1 - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies +ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" #================================================= # REMOVE NGINX CONFIGURATION @@ -57,6 +49,24 @@ ynh_script_progression --message="Removing NGINX web server configuration..." -- # Remove the dedicated NGINX config ynh_remove_nginx_config +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_script_progression --message="Removing dependencies..." --weight=1 + +# Remove metapackage and its dependencies +ynh_remove_app_dependencies + +#================================================= +# SPECIFIC REMOVE +#================================================= +# REMOVE VARIOUS FILES +#================================================= +ynh_script_progression --message="Removing various files..." + +# Remove a directory securely +ynh_secure_remove --file="/etc/$app" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 050f3f8..05b539d 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -22,26 +23,25 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." --weight=1 +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) +port=$(ynh_app_setting_get --app=$app --key=port) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= ynh_script_progression --message="Validating restoration parameters..." --weight=2 -test ! -d $final_path || ynh_die --message="There is already a directory: $final_path " - #================================================= # STANDARD RESTORATION STEPS #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the NGINX configuration..." +ynh_script_progression --message="Restoring the NGINX web server configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" @@ -56,41 +56,32 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=7 ynh_install_app_dependencies $pkg_dependencies #================================================= -# RESTORE SYSTEMD +# RESTORE VARIOUS FILES #================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --weight=5 +ynh_script_progression --message="Restoring various files..." -ynh_restore_file --origin_path="/etc/systemd/system/$app.service" -systemctl enable $app.service +ynh_replace_string --match_string="ListenStream=.*" --replace_string="ListenStream=$port" --target_file="/lib/systemd/system/cockpit.socket" +systemctl daemon-reload +systemctl restart $app.socket + +ynh_restore_file --origin_path="/etc/cockpit/cockpit.conf" #================================================= -# NGINX CONFIGURATION +# INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=2 +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -# Create a dedicated NGINX config -ynh_add_nginx_config +yunohost service add $app #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=2 -# Reload services -ynh_systemd_action --service_name=$app --action="start" -ynh_systemd_action --service_name=$app --action="enable" +ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd" --line_match="Started" #================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Configuring SSOwat..." --weight=1 - -# Make app public if necessary or protect it -if [ $is_public -eq 1 ] -then - ynh_permission_update --permission "main" --add "visitors" -fi - +# GENERIC FINALIZATION #================================================= # RELOAD NGINX #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 84921ee..0f4425f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -30,12 +30,13 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up HedgeDoc before upgrading (may take a while)..." --weight=12 +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 ynh_clean_setup () { - # restore it if the upgrade fails + ynh_clean_check_starting + # Restore it if the upgrade fails ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script @@ -50,13 +51,6 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" -#================================================= -# INSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Installing dependencies..." --weight=20 - -ynh_install_app_dependencies $pkg_dependencies - #================================================= # NGINX CONFIGURATION #================================================= @@ -65,14 +59,41 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=2 # Create a dedicated NGINX config ynh_add_nginx_config +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --weight=20 + +ynh_install_app_dependencies $pkg_dependencies + +#================================================= +# SPECIFIC UPGRADE +#================================================= +# UPDATE A CONFIG FILE +#================================================= +ynh_script_progression --message="Updating a configuration file..." --weight=1 + +ynh_replace_string --match_string="ListenStream=.*" --replace_string="ListenStream=$port" --target_file="/lib/systemd/system/cockpit.socket" +systemctl daemon-reload +systemctl restart $app.socket + +ynh_add_config --template="../conf/cockpit.conf" --destination="/etc/cockpit/cockpit.conf" + +#================================================= +# GENERIC FINALIZATION +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 + +yunohost service add $app + #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=2 -# Reload services -ynh_systemd_action --service_name=$app --action="start" -ynh_systemd_action --service_name=$app --action="enable" +ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd" --line_match="Started" #================================================= # RELOAD NGINX @@ -85,4 +106,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --last +ynh_script_progression --message="Upgrade of $app completed" --last From cd3cd18dd4438fe2f8cccd0d226b1a314981553e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 14 Mar 2022 22:02:10 +0100 Subject: [PATCH 10/14] Fix upgrade --- scripts/upgrade | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/upgrade b/scripts/upgrade index 0f4425f..ebdac3e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -17,6 +17,7 @@ ynh_script_progression --message="Loading installation settings..." --weight=2 app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) From 87f24a40864f28a4b439d7e2f5521148fb081cf9 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Mon, 14 Mar 2022 21:02:14 +0000 Subject: [PATCH 11/14] Auto-update README --- README.md | 3 +++ README_fr.md | 3 +++ 2 files changed, 6 insertions(+) diff --git a/README.md b/README.md index 5d95937..b5f117a 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Cockpit is a web-based graphical interface for servers, intended for everyone. + + **Shipped version:** 257~ynh1 @@ -29,6 +31,7 @@ Cockpit is a web-based graphical interface for servers, intended for everyone. * Official app website: https://cockpit-project.org/ * Official admin documentation: https://cockpit-project.org/documentation.html +* Upstream app code repository: https://github.com/cockpit-project/cockpit * YunoHost documentation for this app: https://yunohost.org/app_cockpit * Report a bug: https://github.com/YunoHost-Apps/cockpit_ynh/issues diff --git a/README_fr.md b/README_fr.md index b55e13d..0d68f3a 100644 --- a/README_fr.md +++ b/README_fr.md @@ -13,6 +13,8 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour Cockpit is a web-based graphical interface for servers, intended for everyone. + + **Version incluse :** 257~ynh1 @@ -25,6 +27,7 @@ Cockpit is a web-based graphical interface for servers, intended for everyone. * Site officiel de l'app : https://cockpit-project.org/ * Documentation officielle de l'admin : https://cockpit-project.org/documentation.html +* Dépôt de code officiel de l'app : https://github.com/cockpit-project/cockpit * Documentation YunoHost pour cette app : https://yunohost.org/app_cockpit * Signaler un bug : https://github.com/YunoHost-Apps/cockpit_ynh/issues From 2d9cf5c2082d06539cb7ac0eb50e466c29660a50 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 18 Mar 2022 00:49:57 +0100 Subject: [PATCH 12/14] Fix version --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 3fbccec..2a5a79f 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Sysadmin login session in a web browser", "fr": "Session de connexion sysadmin dans un navigateur Web" }, - "version": "257~ynh1", + "version": "188~ynh1", "url": "https://cockpit-project.org/", "upstream": { "license": "LGPL-2.1-only", From 44191a556fec705024b1b613f1b5389a2c729bf6 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Thu, 17 Mar 2022 23:50:01 +0000 Subject: [PATCH 13/14] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b5f117a..ebfd413 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Cockpit is a web-based graphical interface for servers, intended for everyone. -**Shipped version:** 257~ynh1 +**Shipped version:** 188~ynh1 diff --git a/README_fr.md b/README_fr.md index 0d68f3a..2681e2e 100644 --- a/README_fr.md +++ b/README_fr.md @@ -15,7 +15,7 @@ Cockpit is a web-based graphical interface for servers, intended for everyone. -**Version incluse :** 257~ynh1 +**Version incluse :** 188~ynh1 From 1c0f113ab849c789e3f38eb35db8b265503ac69e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 18 Mar 2022 16:33:03 +0100 Subject: [PATCH 14/14] Fix path --- conf/cockpit.conf | 4 ++-- conf/nginx.conf | 11 +++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/conf/cockpit.conf b/conf/cockpit.conf index 363e627..c6ed880 100644 --- a/conf/cockpit.conf +++ b/conf/cockpit.conf @@ -1,4 +1,4 @@ [WebService] +Origins = https://__DOMAIN__ wss://__DOMAIN__ ProtocolHeader = X-Forwarded-Proto - -UrlRoot = __PATH__/ \ No newline at end of file +UrlRoot = __PATH__ \ No newline at end of file diff --git a/conf/nginx.conf b/conf/nginx.conf index d386d46..cf49999 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,18 +1,13 @@ #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; -location ^~ __PATH__/ { +location __PATH__/ { - proxy_pass http://127.0.0.1:__PORT__/; + proxy_pass https://127.0.0.1:__PORT____PATH__/; proxy_http_version 1.1; proxy_buffering off; - proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; - proxy_set_header X-Forwarded-For $remote_addr; - - # needed for websocket + proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; - # change scheme of "Origin" to http - proxy_set_header Origin http://$host; # Include SSOWAT user panel.