1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/code-server_ynh.git synced 2024-09-03 18:16:28 +02:00
This commit is contained in:
Tagada 2023-06-11 16:27:35 +02:00
parent ce90098522
commit 693a388aa2
12 changed files with 199 additions and 160 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -3,5 +3,5 @@ auth: __AUTH__
cert: false cert: false
disable-telemetry: true disable-telemetry: true
disable-update-check: true disable-update-check: true
user-data-dir: __DATADIR__/user-data user-data-dir: __DATA_DIR__/user-data
extensions-dir: __DATADIR__/extensions extensions-dir: __DATA_DIR__/extensions

View file

@ -7,8 +7,8 @@ Type=simple
User=__ADMIN__ User=__ADMIN__
Group=__ADMIN__ Group=__ADMIN__
WorkingDirectory=/home/__ADMIN__/ WorkingDirectory=/home/__ADMIN__/
EnvironmentFile=__FINALPATH__/code-server.env EnvironmentFile=__INSTALL_DIR__/code-server.env
ExecStart=__FINALPATH__/bin/code-server --config __FINALPATH__/config.yaml ExecStart=__INSTALL_DIR__/bin/code-server --config __INSTALL_DIR__/config.yaml
StandardOutput=append:/var/log/__APP__/__APP__.log StandardOutput=append:/var/log/__APP__/__APP__.log
StandardError=inherit StandardError=inherit

58
manifest.toml Normal file
View file

@ -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 = "/"

View file

@ -14,23 +14,23 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script. ### Remove this function if there's nothing to clean before calling the remove script.
true true
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # 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) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
domain=$(ynh_app_setting_get --app=$app --key=domain) #REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
datadir=$(ynh_app_setting_get --app=$app --key=datadir) #REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
#================================================= #=================================================
# DECLARE DATA AND CONF FILES TO BACKUP # 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 # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_backup --src_path="$final_path" ynh_backup --src_path="$install_dir"
#================================================= #=================================================
# BACKUP THE DATA DIR # BACKUP THE DATA DIR
#================================================= #=================================================
ynh_backup --src_path="$datadir" --is_big ynh_backup --src_path="$data_dir" --is_big
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION

View file

@ -13,47 +13,47 @@ source /usr/share/yunohost/helpers
# RETRIEVE ARGUMENTS # RETRIEVE ARGUMENTS
#================================================= #=================================================
old_domain=$YNH_APP_OLD_DOMAIN #REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH #REMOVEME? old_path=$YNH_APP_OLD_PATH
new_domain=$YNH_APP_NEW_DOMAIN #REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN
new_path='/' #REMOVEME? new_path='/'
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# LOAD SETTINGS # 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" #REMOVEME? # Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#================================================= #=================================================
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP # 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 # Backup the current version of the app
ynh_backup_before_upgrade #REMOVEME? ynh_backup_before_upgrade
ynh_clean_setup () { #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. # 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 # Restore it if the upgrade fails
ynh_restore_upgradebackup #REMOVEME? ynh_restore_upgradebackup
} }
# Exit if an error occurs during the execution of the script # 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 # CHECK WHICH PARTS SHOULD BE CHANGED
#================================================= #=================================================
change_domain=0 #REMOVEME? change_domain=0
if [ "$old_domain" != "$new_domain" ] #REMOVEME? if [ "$old_domain" != "$new_domain" ]
then then
change_domain=1 #REMOVEME? change_domain=1
fi 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 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 # Change the domain for NGINX
if [ $change_domain -eq 1 ] if [ $change_domain -eq 1 ]
then then
# Delete file checksum for the old conf file location # Delete file checksum for the old conf file location
ynh_delete_file_checksum --file="$nginx_conf_path" #REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf #REMOVEME? mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location # 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 fi
#================================================= #=================================================
@ -100,9 +102,9 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap
#================================================= #=================================================
# RELOAD NGINX # 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 # END OF SCRIPT

View file

@ -13,32 +13,32 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
true true
} }
# Exit if an error occurs during the execution of the script # 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 # RETRIEVE ARGUMENTS FROM THE MANIFEST
#================================================= #=================================================
domain=$YNH_APP_ARG_DOMAIN #REMOVEME? domain=$YNH_APP_ARG_DOMAIN
admin=$YNH_APP_ARG_ADMIN #REMOVEME? admin=$YNH_APP_ARG_ADMIN
auth="none" auth="none"
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # 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 #REMOVEME? install_dir=/opt/yunohost/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder" #REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder"
# Register (book) web path # 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) # Check machine architecture (in particular, we don't support 32bit machines)
if [ $YNH_ARCH == "i386" ] || [ $YNH_ARCH == "armel" ] if [ $YNH_ARCH == "i386" ] || [ $YNH_ARCH == "armel" ]
@ -49,10 +49,10 @@ fi
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # 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 #REMOVEME? 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=admin --value=$admin
ynh_app_setting_set --app=$app --key=auth --value=$auth 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 # 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 # Find an available port
port=$(ynh_find_port --port=8095) #REMOVEME? port=$(ynh_find_port --port=8095)
ynh_app_setting_set --app=$app --key=port --value=$port #REMOVEME? ynh_app_setting_set --app=$app --key=port --value=$port
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=5 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 # 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 750 "$install_dir"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$install_dir"
chown -R root:$admin "$final_path" chown -R root:$admin "$install_dir"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
@ -98,29 +98,29 @@ ynh_add_nginx_config
#================================================= #=================================================
ynh_script_progression --message="Creating a data directory..." --weight=2 ynh_script_progression --message="Creating a data directory..." --weight=2
datadir=/home/$app/.local/share/code-server #REMOVEME? data_dir=/home/$app/.local/share/code-server
ynh_app_setting_set --app=$app --key=datadir --value=$datadir #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 750 "$data_dir"
chmod -R o-rwx "$datadir" chmod -R o-rwx "$data_dir"
chown -R $admin:$admin "$datadir" chown -R $admin:$admin "$data_dir"
#================================================= #=================================================
# ADD A CONFIGURATION # ADD A CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=2 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" chmod 440 "$install_dir/config.yaml"
chown root:$admin "$final_path/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" chmod 440 "$install_dir/code-server.env"
chown root:$admin "$final_path/code-server.env" chown root:$admin "$install_dir/code-server.env"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
@ -157,17 +157,17 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap
#================================================= #=================================================
# SETUP SSOWAT # 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" #REMOVEME? ynh_permission_update --permission="main" --remove="all_users"
ynh_permission_update --permission="main" --add=$admin #REMOVEME? ynh_permission_update --permission="main" --add=$admin
#================================================= #=================================================
# RELOAD NGINX # 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 # END OF SCRIPT

View file

@ -12,14 +12,14 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # 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) #REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port) #REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
datadir=$(ynh_app_setting_get --app=$app --key=datadir) #REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
@ -53,10 +53,10 @@ ynh_remove_logrotate
#================================================= #=================================================
# REMOVE APP MAIN DIR # 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 # Remove the app directory securely
ynh_secure_remove --file="$final_path" #REMOVEME? ynh_secure_remove --file="$install_dir"
#================================================= #=================================================
# REMOVE DATA DIR # REMOVE DATA DIR
@ -66,7 +66,7 @@ ynh_secure_remove --file="$final_path"
if [ "${YNH_APP_PURGE:-0}" -eq 1 ] if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
then then
ynh_script_progression --message="Removing app data directory..." --weight=1 ynh_script_progression --message="Removing app data directory..." --weight=1
ynh_secure_remove --file="$datadir" #REMOVEME? ynh_secure_remove --file="$data_dir"
fi fi
#================================================= #=================================================

View file

@ -14,32 +14,32 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
#### Remove this function if there's nothing to clean before calling the remove script. #### Remove this function if there's nothing to clean before calling the remove script.
true true
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # 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) #REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
admin=$(ynh_app_setting_get --app=$app --key=admin) #REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
datadir=$(ynh_app_setting_get --app=$app --key=datadir) #REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # 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 \ #REMOVEME? test ! -d $install_dir \
|| ynh_die --message="There is already a directory: $final_path " || ynh_die --message="There is already a directory: $install_dir "
ynh_user_exists --username=$admin || ynh_die --message="User $admin doesn't exist " 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_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 750 "$install_dir"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$install_dir"
chown -R root:$admin "$final_path" chown -R root:$admin "$install_dir"
#================================================= #=================================================
# RESTORE THE DATA DIRECTORY # RESTORE THE DATA DIRECTORY
#================================================= #=================================================
ynh_script_progression --message="Restoring the data directory..." --weight=1 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 750 "$data_dir"
chmod -R o-rwx "$datadir" chmod -R o-rwx "$data_dir"
chown -R $admin:$admin "$datadir" chown -R $admin:$admin "$data_dir"
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION

View file

@ -12,19 +12,19 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # 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) #REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
admin=$(ynh_app_setting_get --app=$app --key=admin) #REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin)
port=$(ynh_app_setting_get --app=$app --key=port) #REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
datadir=$(ynh_app_setting_get --app=$app --key=datadir) #REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
auth=$(ynh_app_setting_get --app=$app --key=auth) #REMOVEME? auth=$(ynh_app_setting_get --app=$app --key=auth)
hashed_password=$(ynh_app_setting_get --app=$app --key=hashed_password) #REMOVEME? hashed_password=$(ynh_app_setting_get --app=$app --key=hashed_password)
enable_proposed_api=$(ynh_app_setting_get --app=$app --key="enable_proposed_api") #REMOVEME? 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? extensions_gallery=$(ynh_app_setting_get --app=$app --key="extensions_gallery")
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
@ -35,16 +35,16 @@ upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # 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 # Backup the current version of the app
ynh_backup_before_upgrade #REMOVEME? ynh_backup_before_upgrade
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
# Restore it if the upgrade fails # Restore it if the upgrade fails
ynh_restore_upgradebackup #REMOVEME? ynh_restore_upgradebackup
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# STANDARD UPGRADE STEPS # 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" if ynh_compare_current_package_version -c le -v "3.11.0~ynh1"
then then
extension_service_url=$(ynh_app_setting_get --app=$app --key="extension_service_url") #REMOVEME? 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_item_url=$(ynh_app_setting_get --app=$app --key="extension_item_url")
if [ "$extension_service_url" ] && [ "$extension_item_url" ] if [ "$extension_service_url" ] && [ "$extension_item_url" ]
then then
@ -93,20 +93,20 @@ then
ynh_remove_fail2ban_config ynh_remove_fail2ban_config
ynh_secure_remove --file=$final_path #REMOVEME? ynh_secure_remove --file=$install_dir
mkdir -p $final_path mkdir -p $install_dir
fi fi
if ynh_compare_current_package_version -c le -v "4.1.0~ynh1" if ynh_compare_current_package_version -c le -v "4.1.0~ynh1"
then then
new_datadir=/home/$app/.local/share/code-server new_data_dir=/home/$app/.local/share/code-server
mkdir -p $new_datadir mkdir -p $new_data_dir
cp -R $datadir/* $new_datadir cp -R $data_dir/* $new_data_dir
ynh_secure_remove --file=$datadir #REMOVEME? ynh_secure_remove --file=$data_dir
datadir=new_datadir data_dir=new_data_dir
ynh_app_setting_set --app=$app --key=datadir --value=$datadir #REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir
fi fi
#================================================= #=================================================
@ -118,12 +118,12 @@ then
ynh_script_progression --message="Upgrading source files..." --weight=1 ynh_script_progression --message="Upgrading source files..." --weight=1
# Download, check integrity, uncompress and patch the source from app.src # 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 fi
chmod 750 "$final_path" chmod 750 "$install_dir"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$install_dir"
chown -R root:$admin "$final_path" chown -R root:$admin "$install_dir"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
@ -144,16 +144,16 @@ ynh_add_nginx_config
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=1 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="config.yaml" --destination="$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"
if [ "$auth" == "password" ] if [ "$auth" == "password" ]
then then
echo "hashed-password: $hashed_password" >> "$final_path/config.yaml" echo "hashed-password: $hashed_password" >> "$install_dir/config.yaml"
fi fi
chmod 440 "$final_path/config.yaml" "$final_path/code-server.env" chmod 440 "$install_dir/config.yaml" "$install_dir/code-server.env"
chown root:$admin "$final_path/config.yaml" "$final_path/code-server.env" chown root:$admin "$install_dir/config.yaml" "$install_dir/code-server.env"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
@ -190,9 +190,9 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap
#================================================= #=================================================
# RELOAD NGINX # 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 # END OF SCRIPT