diff --git a/conf/amd64.src b/conf/amd64.src deleted file mode 100644 index 18e56f3..0000000 --- a/conf/amd64.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://github.com/coder/code-server/releases/download/v4.13.0/code-server-4.13.0-linux-amd64.tar.gz -SOURCE_SUM=de103fb2d7f6df1395c6a6692c1dccb1474895cd2bc467be457e039ab9d858ac -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= -SOURCE_EXTRACT=true diff --git a/conf/arm64.src b/conf/arm64.src deleted file mode 100644 index 7eaed70..0000000 --- a/conf/arm64.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://github.com/coder/code-server/releases/download/v4.13.0/code-server-4.13.0-linux-arm64.tar.gz -SOURCE_SUM=e9d81ae13a6f02c3350c0eca021d6b0b381bf459475fcbcc3e861fa3d19b1eff -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= -SOURCE_EXTRACT=true diff --git a/conf/armhf.src b/conf/armhf.src deleted file mode 100644 index 38bfaea..0000000 --- a/conf/armhf.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://github.com/coder/code-server/releases/download/v4.13.0/code-server-4.13.0-linux-armv7l.tar.gz -SOURCE_SUM=20aed6fb13424edc2c1997e3241dc4c7d51a29e0a3e7349696715f61d10762c7 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= -SOURCE_EXTRACT=true diff --git a/conf/config.yaml b/conf/config.yaml index 2194c32..9a2e7db 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -3,5 +3,5 @@ auth: __AUTH__ cert: false disable-telemetry: true disable-update-check: true -user-data-dir: __DATADIR__/user-data -extensions-dir: __DATADIR__/extensions +user-data-dir: __DATA_DIR__/user-data +extensions-dir: __DATA_DIR__/extensions diff --git a/conf/systemd.service b/conf/systemd.service index 57b47bf..c0e5e96 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -7,8 +7,8 @@ Type=simple User=__ADMIN__ Group=__ADMIN__ WorkingDirectory=/home/__ADMIN__/ -EnvironmentFile=__FINALPATH__/code-server.env -ExecStart=__FINALPATH__/bin/code-server --config __FINALPATH__/config.yaml +EnvironmentFile=__INSTALL_DIR__/code-server.env +ExecStart=__INSTALL_DIR__/bin/code-server --config __INSTALL_DIR__/config.yaml StandardOutput=append:/var/log/__APP__/__APP__.log StandardError=inherit diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..bb229d6 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,58 @@ +packaging_format = 2 + +id = "code-server" +name = "code-server" +description.en = "Run VS Code on your server and access it in the browser" +description.fr = "Lancez VS Code sur votre serveur et accédez-y depuis votre navigateur" + +version = "4.12.0~ynh1" + +maintainers = ["Tagada"] + +[upstream] +license = "MIT" +website = "https://coder.com" +admindoc = "https://coder.com/docs/code-server/latest" +userdoc = "https://coder.com/docs/code-server/latest/FAQ" +code = "https://github.com/coder/code-server" +cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number) +fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin. + +[integration] +yunohost = ">= 4.3.1.8" +architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"] +multi_instance = true +ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials. +sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal. +disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... +ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... +ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... + +[install] + [install.domain] + # this is a generic question - ask strings are automatically handled by Yunohost's core + type = "domain" + full_domain = true + + [install.admin] + # this is a generic question - ask strings are automatically handled by Yunohost's core + type = "user" + +[resources] + [resources.sources.main] + arm64.url = "https://github.com/coder/code-server/releases/download/v4.12.0/code-server-4.12.0-linux-arm64.tar.gz" + arm64.sha256 = "2cddd82a010f61a4bd20d6cc3c50e924b01a83e938e5e4e882e36a541208f7c8" + amd64.url = "https://github.com/coder/code-server/releases/download/v4.12.0/code-server-4.12.0-linux-amd64.tar.gz" + amd64.sha256 = "d50ee947c4144a6ff2656e664ecbb3f70b75168b8a6e8c3eef47787f3c240c26" + armhf.url = "https://github.com/coder/code-server/releases/download/v4.12.0/code-server-4.12.0-linux-armv7l.tar.gz" + armhf.sha256 = "fe8e14d2b1e0c5ea3b598dd465e19a52321ab905adce6fc6890efdd5286a0af3" + + + [resources.system_user] + + [resources.install_dir] + + [resources.data_dir] + + [resources.permissions] + main.url = "/" diff --git a/scripts/backup b/scripts/backup index 8367e33..d4459e8 100755 --- a/scripts/backup +++ b/scripts/backup @@ -14,23 +14,23 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? 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 -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading installation settings..." +#REMOVEME? ynh_print_info --message="Loading installation settings..." -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -domain=$(ynh_app_setting_get --app=$app --key=domain) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -41,13 +41,13 @@ 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" #================================================= # BACKUP THE DATA DIR #================================================= -ynh_backup --src_path="$datadir" --is_big +ynh_backup --src_path="$data_dir" --is_big #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/change_url b/scripts/change_url index 5264913..9ff0495 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -13,47 +13,47 @@ source /usr/share/yunohost/helpers # RETRIEVE ARGUMENTS #================================================= -old_domain=$YNH_APP_OLD_DOMAIN -old_path=$YNH_APP_OLD_PATH +#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN +#REMOVEME? old_path=$YNH_APP_OLD_PATH -new_domain=$YNH_APP_NEW_DOMAIN -new_path='/' +#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN +#REMOVEME? new_path='/' -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 -# Needed for helper "ynh_add_nginx_config" -final_path=$(ynh_app_setting_get --app=$app --key=final_path) +#REMOVEME? # Needed for helper "ynh_add_nginx_config" +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) #================================================= # BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1 +#REMOVEME? ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1 # Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { +#REMOVEME? ynh_backup_before_upgrade +#REMOVEME? 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" +#REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" # Restore it if the upgrade fails - ynh_restore_upgradebackup +#REMOVEME? ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED #================================================= -change_domain=0 -if [ "$old_domain" != "$new_domain" ] +#REMOVEME? change_domain=0 +#REMOVEME? if [ "$old_domain" != "$new_domain" ] then - change_domain=1 + #REMOVEME? change_domain=1 fi #================================================= @@ -70,16 +70,18 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app #================================================= ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 -nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf +ynh_change_url_nginx_config + +#REMOVEME? nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf # 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 +#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path" +#REMOVEME? 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" +#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi #================================================= @@ -100,9 +102,9 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 3972f51..05f270d 100755 --- a/scripts/install +++ b/scripts/install @@ -13,32 +13,32 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { true } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -domain=$YNH_APP_ARG_DOMAIN -admin=$YNH_APP_ARG_ADMIN +#REMOVEME? domain=$YNH_APP_ARG_DOMAIN +#REMOVEME? admin=$YNH_APP_ARG_ADMIN auth="none" -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Validating installation parameters..." --weight=1 +#REMOVEME? 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" +#REMOVEME? install_dir=/opt/yunohost/$app +#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder" # Register (book) web path -ynh_webpath_register --app=$app --domain=$domain --path_url="/" +#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path="/" # Check machine architecture (in particular, we don't support 32bit machines) if [ $YNH_ARCH == "i386" ] || [ $YNH_ARCH == "armel" ] @@ -49,10 +49,10 @@ fi #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." --weight=2 +#REMOVEME? ynh_script_progression --message="Storing installation settings..." --weight=2 -ynh_app_setting_set --app=$app --key=domain --value=$domain -ynh_app_setting_set --app=$app --key=admin --value=$admin +#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain +#REMOVEME? ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=auth --value=$auth #================================================= @@ -60,24 +60,24 @@ ynh_app_setting_set --app=$app --key=auth --value=$auth #================================================= # FIND AND OPEN A PORT #================================================= -ynh_script_progression --message="Finding an available port..." --weight=1 +#REMOVEME? ynh_script_progression --message="Finding an available port..." --weight=1 # Find an available port -port=$(ynh_find_port --port=8095) -ynh_app_setting_set --app=$app --key=port --value=$port +#REMOVEME? port=$(ynh_find_port --port=8095) +#REMOVEME? ynh_app_setting_set --app=$app --key=port --value=$port #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=5 -ynh_app_setting_set --app=$app --key=final_path --value=$final_path +#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$final_path" --source_id="$YNH_ARCH" +ynh_setup_source --dest_dir="$install_dir" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R root:$admin "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R root:$admin "$install_dir" #================================================= # NGINX CONFIGURATION @@ -98,29 +98,29 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Creating a data directory..." --weight=2 -datadir=/home/$app/.local/share/code-server -ynh_app_setting_set --app=$app --key=datadir --value=$datadir +#REMOVEME? data_dir=/home/$app/.local/share/code-server +#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir -mkdir -p $datadir/{user-data,extensions} +mkdir -p $data_dir/{user-data,extensions} -chmod 750 "$datadir" -chmod -R o-rwx "$datadir" -chown -R $admin:$admin "$datadir" +chmod 750 "$data_dir" +chmod -R o-rwx "$data_dir" +chown -R $admin:$admin "$data_dir" #================================================= # ADD A CONFIGURATION #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=2 -ynh_add_config --template="config.yaml" --destination="$final_path/config.yaml" +ynh_add_config --template="config.yaml" --destination="$install_dir/config.yaml" -chmod 440 "$final_path/config.yaml" -chown root:$admin "$final_path/config.yaml" +chmod 440 "$install_dir/config.yaml" +chown root:$admin "$install_dir/config.yaml" -ynh_add_config --template="code-server.env" --destination="$final_path/code-server.env" +ynh_add_config --template="code-server.env" --destination="$install_dir/code-server.env" -chmod 440 "$final_path/code-server.env" -chown root:$admin "$final_path/code-server.env" +chmod 440 "$install_dir/code-server.env" +chown root:$admin "$install_dir/code-server.env" #================================================= # SETUP SYSTEMD @@ -157,17 +157,17 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring permissions..." --weight=1 +#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1 -ynh_permission_update --permission="main" --remove="all_users" -ynh_permission_update --permission="main" --add=$admin +#REMOVEME? ynh_permission_update --permission="main" --remove="all_users" +#REMOVEME? ynh_permission_update --permission="main" --add=$admin #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=2 +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=2 -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index edce58f..63e3a33 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,14 +12,14 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -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) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) #================================================= # STANDARD REMOVE @@ -53,10 +53,10 @@ ynh_remove_logrotate #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." --weight=1 +#REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=1 # Remove the app directory securely -ynh_secure_remove --file="$final_path" +#REMOVEME? ynh_secure_remove --file="$install_dir" #================================================= # REMOVE DATA DIR @@ -66,7 +66,7 @@ ynh_secure_remove --file="$final_path" if [ "${YNH_APP_PURGE:-0}" -eq 1 ] then ynh_script_progression --message="Removing app data directory..." --weight=1 - ynh_secure_remove --file="$datadir" +#REMOVEME? ynh_secure_remove --file="$data_dir" fi #================================================= diff --git a/scripts/restore b/scripts/restore index d9f8287..59dd080 100755 --- a/scripts/restore +++ b/scripts/restore @@ -14,32 +14,32 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? 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 -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) -admin=$(ynh_app_setting_get --app=$app --key=admin) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." --weight=1 +#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1 -test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path " +#REMOVEME? test ! -d $install_dir \ + || ynh_die --message="There is already a directory: $install_dir " ynh_user_exists --username=$admin || ynh_die --message="User $admin doesn't exist " #================================================= @@ -56,24 +56,24 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= 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 root:$admin "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R root:$admin "$install_dir" #================================================= # RESTORE THE DATA DIRECTORY #================================================= ynh_script_progression --message="Restoring the data directory..." --weight=1 -ynh_restore_file --origin_path="$datadir" --not_mandatory +ynh_restore_file --origin_path="$data_dir" --not_mandatory -mkdir -p $datadir/{user-data,extensions} +mkdir -p $data_dir/{user-data,extensions} -chmod 750 "$datadir" -chmod -R o-rwx "$datadir" -chown -R $admin:$admin "$datadir" +chmod 750 "$data_dir" +chmod -R o-rwx "$data_dir" +chown -R $admin:$admin "$data_dir" #================================================= # SPECIFIC RESTORATION diff --git a/scripts/upgrade b/scripts/upgrade index 76bb9cb..fc18810 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,19 +12,19 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) -admin=$(ynh_app_setting_get --app=$app --key=admin) -port=$(ynh_app_setting_get --app=$app --key=port) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) -auth=$(ynh_app_setting_get --app=$app --key=auth) -hashed_password=$(ynh_app_setting_get --app=$app --key=hashed_password) -enable_proposed_api=$(ynh_app_setting_get --app=$app --key="enable_proposed_api") -extensions_gallery=$(ynh_app_setting_get --app=$app --key="extensions_gallery") +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin) +#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) +#REMOVEME? auth=$(ynh_app_setting_get --app=$app --key=auth) +#REMOVEME? hashed_password=$(ynh_app_setting_get --app=$app --key=hashed_password) +#REMOVEME? enable_proposed_api=$(ynh_app_setting_get --app=$app --key="enable_proposed_api") +#REMOVEME? extensions_gallery=$(ynh_app_setting_get --app=$app --key="extensions_gallery") #================================================= # CHECK VERSION @@ -35,16 +35,16 @@ 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 +#REMOVEME? 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 () { +#REMOVEME? ynh_backup_before_upgrade +#REMOVEME? ynh_clean_setup () { # Restore it if the upgrade fails - ynh_restore_upgradebackup +#REMOVEME? ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # STANDARD UPGRADE STEPS @@ -62,8 +62,8 @@ ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 if ynh_compare_current_package_version -c le -v "3.11.0~ynh1" then - extension_service_url=$(ynh_app_setting_get --app=$app --key="extension_service_url") - extension_item_url=$(ynh_app_setting_get --app=$app --key="extension_item_url") +#REMOVEME? extension_service_url=$(ynh_app_setting_get --app=$app --key="extension_service_url") +#REMOVEME? extension_item_url=$(ynh_app_setting_get --app=$app --key="extension_item_url") if [ "$extension_service_url" ] && [ "$extension_item_url" ] then @@ -93,20 +93,20 @@ then ynh_remove_fail2ban_config - ynh_secure_remove --file=$final_path - mkdir -p $final_path +#REMOVEME? ynh_secure_remove --file=$install_dir + mkdir -p $install_dir fi if ynh_compare_current_package_version -c le -v "4.1.0~ynh1" then - new_datadir=/home/$app/.local/share/code-server - mkdir -p $new_datadir + new_data_dir=/home/$app/.local/share/code-server + mkdir -p $new_data_dir - cp -R $datadir/* $new_datadir - ynh_secure_remove --file=$datadir + cp -R $data_dir/* $new_data_dir +#REMOVEME? ynh_secure_remove --file=$data_dir - datadir=new_datadir - ynh_app_setting_set --app=$app --key=datadir --value=$datadir + data_dir=new_data_dir +#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir fi #================================================= @@ -118,12 +118,12 @@ 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="$final_path" --source_id="$YNH_ARCH" + ynh_setup_source --dest_dir="$install_dir" fi -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R root:$admin "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R root:$admin "$install_dir" #================================================= # NGINX CONFIGURATION @@ -144,16 +144,16 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Updating a configuration file..." --weight=1 -ynh_add_config --template="config.yaml" --destination="$final_path/config.yaml" -ynh_add_config --template="code-server.env" --destination="$final_path/code-server.env" +ynh_add_config --template="config.yaml" --destination="$install_dir/config.yaml" +ynh_add_config --template="code-server.env" --destination="$install_dir/code-server.env" if [ "$auth" == "password" ] then - echo "hashed-password: $hashed_password" >> "$final_path/config.yaml" + echo "hashed-password: $hashed_password" >> "$install_dir/config.yaml" fi -chmod 440 "$final_path/config.yaml" "$final_path/code-server.env" -chown root:$admin "$final_path/config.yaml" "$final_path/code-server.env" +chmod 440 "$install_dir/config.yaml" "$install_dir/code-server.env" +chown root:$admin "$install_dir/config.yaml" "$install_dir/code-server.env" #================================================= # SETUP SYSTEMD @@ -190,9 +190,9 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT