From 57cd4895cf1e144952c1a18ce2a5346d491f7016 Mon Sep 17 00:00:00 2001 From: Jules Bertholet Date: Tue, 6 Apr 2021 16:14:55 -0400 Subject: [PATCH] Remove comments --- scripts/backup | 9 ------ scripts/install | 85 ------------------------------------------------- scripts/restore | 1 - scripts/upgrade | 18 ----------- 4 files changed, 113 deletions(-) diff --git a/scripts/backup b/scripts/backup index 569ccff..e56e6b8 100755 --- a/scripts/backup +++ b/scripts/backup @@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. true } # Exit if an error occurs during the execution of the script @@ -37,11 +36,6 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= ynh_print_info --message="Declaring files to be backed up..." -### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs -### to be backuped and not an actual copy of any file. The actual backup that -### creates and fill the archive with the files happens in the core after this -### script is called. Hence ynh_backups calls takes basically 0 seconds to run. - #================================================= # BACKUP THE APP MAIN DIR #================================================= @@ -87,9 +81,6 @@ ynh_backup --src_path="/var/log/$app" #================================================= ynh_print_info --message="Backing up the MySQL database..." -### (However, things like MySQL dumps *do* take some time to run, though the -### copy of the generated dump to the archive still happens later) - ynh_mysql_dump_db --database="$db_name" > db.sql #================================================= diff --git a/scripts/install b/scripts/install index 516ab9d..7ed5ae3 100755 --- a/scripts/install +++ b/scripts/install @@ -14,7 +14,6 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. true } # Exit if an error occurs during the execution of the script @@ -29,16 +28,6 @@ path_url=$YNH_APP_ARG_PATH admin=$YNH_APP_ARG_ADMIN is_public=$YNH_APP_ARG_IS_PUBLIC -### If it's a multi-instance app, meaning it can be installed several times independently -### The id of the app as stated in the manifest is available as $YNH_APP_ID -### The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2"...) -### The app instance name is available as $YNH_APP_INSTANCE_NAME -### - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample -### - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2 -### - ynhexample__{N} for the subsequent installations, with N=3,4... -### The app instance name is probably what interests you most, since this is -### guaranteed to be unique. This is a good unique identifier to define installation path, -### db names... app=$YNH_APP_INSTANCE_NAME #================================================= @@ -46,8 +35,6 @@ app=$YNH_APP_INSTANCE_NAME #================================================= ynh_script_progression --message="Validating installation parameters..." --weight=1 -### If the app uses NGINX as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app". -### If the app provides an internal web server (or uses another application server such as uWSGI), the final path should be "/opt/yunohost/$app" final_path=/opt/yunohost/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" @@ -70,9 +57,6 @@ ynh_app_setting_set --app=$app --key=admin --value=$admin #================================================= ynh_script_progression --message="Finding available ports..." --weight=1 -### Use these lines if you have to open a port for the application -### `ynh_find_port` will find the first available port starting from the given port. - # Find available ports guacd_port=$(ynh_find_port --port=4822) ynh_app_setting_set --app=$app --key=guacd_port --value=$guacd_port @@ -84,9 +68,6 @@ ynh_app_setting_set --app=$app --key=port --value=$port #================================================= ynh_script_progression --message="Installing dependencies..." --weight=1 -### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package. -### Those deb packages will be installed as dependencies of this package. - # Guacamole depends on Apache Tomcat. # But installing Tomcat from the Debian repos automatically enables and starts it. # So we stop and disable it, unless Tomcat was already enabled or started by the user beforehand @@ -116,15 +97,6 @@ fi #================================================= ynh_script_progression --message="Creating a MySQL database..." --weight=1 -### Use these lines if you need a database for the application. -### `ynh_mysql_setup_db` will create a database, an associated user and a ramdom password. -### The password will be stored as 'mysqlpwd' into the app settings, -### and will be available as $db_pwd -### If you're not using these lines: -### - Remove the section "BACKUP THE MYSQL DATABASE" in the backup script -### - Remove also the section "REMOVE THE MYSQL DATABASE" in the remove script -### - As well as the section "RESTORE THE MYSQL DATABASE" in the restore script - db_name=$(ynh_sanitize_dbid --db_name=$app) db_user=$db_name ynh_app_setting_set --app=$app --key=db_name --value=$db_name @@ -135,10 +107,6 @@ ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name #================================================= ynh_script_progression --message="Setting up source files..." --weight=3 -### `ynh_setup_source` is used to install an app from a zip or tar.gz file, -### downloaded from an upstream source, like a git repository. -### `ynh_setup_source` use the file conf/app.src - 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 --source_id="server" --dest_dir="$final_path/.guacd-src" @@ -195,8 +163,6 @@ ynh_secure_remove --file="$final_path/etc/guacamole/extensions/mysql-schema" #================================================= ynh_script_progression --message="Configuring NGINX web server..." --weight=1 -### `ynh_add_nginx_config` will use the file conf/nginx.conf - # Create a dedicated NGINX config ynh_add_nginx_config @@ -241,17 +207,6 @@ mkdir -p "/var/log/$app/tomcat/" "/var/log/$app/guacd/" "/var/log/$app/tomcat/" #================================================= ynh_script_progression --message="Configuring systemd services..." --weight=1 -### `ynh_systemd_config` is used to configure a systemd script for an app. -### It can be used for apps that use sysvinit (with adaptation) or systemd. -### Have a look at the app to be sure this app needs a systemd script. -### `ynh_systemd_config` will use the file conf/systemd.service -### If you're not using these lines: -### - You can remove those files in conf/. -### - Remove the section "BACKUP SYSTEMD" in the backup script -### - Remove also the section "STOP AND REMOVE SERVICE" in the remove script -### - As well as the section "RESTORE SYSTEMD" in the restore script -### - And the section "SETUP SYSTEMD" in the upgrade script - # Create dedicated systemd configs ynh_add_systemd_config --service="$app-guacd" --template="guacd.service" -v guacd_port ynh_add_systemd_config --service="$app-tomcat" --template="tomcat.service" @@ -260,24 +215,8 @@ ynh_add_systemd_config --service="$app-tomcat" --template="tomcat.service" # ADD CONFIGURATIONS #================================================= -### You can add specific configuration files. -### -### Typically, put your template conf file in ../conf/your_config_file -### The template may contain strings such as __FOO__ or __FOO_BAR__, -### which will automatically be replaced by the values of $foo and $foo_bar -### -### ynh_add_config will also keep track of the config file's checksum, -### which later during upgrade may allow to automatically backup the config file -### if it's found that the file was manually modified -### -### Check the documentation of `ynh_add_config` for more info. - ynh_add_config --template="guacamole.properties" --destination="$final_path/etc/guacamole/guacamole.properties" -### For more complex cases where you want to replace stuff using regexes, -### you shoud rely on ynh_replace_string (which is basically a wrapper for sed) -### When doing so, you also need to manually call ynh_store_file_checksum -### ynh_replace_string --match_string="8080" --replace_string="$port" --target_file="$final_path/etc/tomcat9/server.xml" #================================================= @@ -286,10 +225,6 @@ ynh_replace_string --match_string="8080" --replace_string="$port" --target_file= # SECURE FILES AND DIRECTORIES #================================================= -### For security reason, any app should set the permissions to root: before anything else. -### Then, if write authorization is needed, any access should be given only to directories -### that really need such authorization. - # Set permissions to app files chown -R root:root $final_path chmod -R o-rwx $final_path @@ -306,14 +241,6 @@ setfacl -n -R -m user:$app-guacd:- -m default:user:$app-guacd:- "$final_path/var #================================================= ynh_script_progression --message="Configuring log rotation..." --weight=1 -### `ynh_use_logrotate` is used to configure a logrotate configuration for the logs of this app. -### Use this helper only if there is effectively a log file for this app. -### If you're not using this helper: -### - Remove the section "BACKUP LOGROTATE" in the backup script -### - Remove also the section "REMOVE LOGROTATE CONFIGURATION" in the remove script -### - As well as the section "RESTORE THE LOGROTATE CONFIGURATION" in the restore script -### - And the section "SETUP LOGROTATE" in the upgrade script - # Use logrotate to manage application logfile(s) ynh_use_logrotate --logfile="/var/log/$app/tomcat/catalina.out" --specific_user="$app-tomcat/$app-tomcat" @@ -322,15 +249,6 @@ ynh_use_logrotate --logfile="/var/log/$app/tomcat/catalina.out" --specific_user= #================================================= ynh_script_progression --message="Integrating services in YunoHost..." --weight=1 -### `yunohost service add` integrates a service in YunoHost. It then gets -### displayed in the admin interface and through the others `yunohost service` commands. -### (N.B.: this line only makes sense if the app adds a service to the system!) -### If you're not using these lines: -### - You can remove these files in conf/. -### - Remove the section "REMOVE SERVICE INTEGRATION IN YUNOHOST" in the remove script -### - As well as the section "INTEGRATE SERVICES IN YUNOHOST" in the restore script -### - And the section "INTEGRATE SERVICES IN YUNOHOST" in the upgrade script - yunohost service add "$app-guacd" --description="Guacamole server" --log="/var/log/$app/guacd.log" yunohost service add "$app-tomcat" --description="Guacamole client" --log="/var/log/$app/tomcat.log" @@ -339,9 +257,6 @@ yunohost service add "$app-tomcat" --description="Guacamole client" --log="/var/ #================================================= ynh_script_progression --message="Starting systemd services..." --weight=1 -### `ynh_systemd_action` is used to start a systemd service for an app. -### Only needed if you have configure a systemd service - # Start systemd services ynh_systemd_action --service_name="$app-guacd" --action="start" --log_path="/var/log/$app/guacd.log" ynh_systemd_action --service_name="$app-tomcat" --action="start" --log_path="/var/log/$app/tomcat.log" diff --git a/scripts/restore b/scripts/restore index 1caf853..f580fa6 100755 --- a/scripts/restore +++ b/scripts/restore @@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - #### Remove this function if there's nothing to clean before calling the remove script. true } # Exit if an error occurs during the execution of the script diff --git a/scripts/upgrade b/scripts/upgrade index efff305..c9d4346 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -31,12 +31,6 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) # CHECK VERSION #================================================= -### This helper will compare the version of the currently installed app and the version of the upstream package. -### $upgrade_type can have 2 different values -### - UPGRADE_APP if the upstream app version has changed -### - UPGRADE_PACKAGE if only the YunoHost package has changed -### ynh_check_app_version_changed will stop the upgrade if the app is up to date. -### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do. upgrade_type=$(ynh_check_app_version_changed) #================================================= @@ -195,20 +189,8 @@ ynh_add_systemd_config --service="$app-tomcat" --template="tomcat.service" # UPDATE CONFIG FILES #================================================= -### Same as during install -### -### The file will automatically be backed-up if it's found to be manually modified (because -### ynh_add_config keeps track of the file's checksum) - ynh_add_config --template="guacamole.properties" --destination="$final_path/etc/guacamole/guacamole.properties" -### For more complex cases where you want to replace stuff using regexes, -### you shoud rely on ynh_replace_string (which is basically a wrapper for sed) -### When doing so, you also need to manually call ynh_store_file_checksum -### -### ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$final_path/some_config_file" -### ynh_store_file_checksum --file="$final_path/some_config_file" - ynh_replace_string --match_string="8080" --replace_string="$port" --target_file="$final_path/etc/tomcat9/server.xml" #=================================================