1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/thelounge_ynh.git synced 2024-09-03 20:35:54 +02:00

Add rights

This commit is contained in:
ericgaspar 2021-08-02 08:23:59 +02:00
parent 2271835381
commit 643d8a3f29
9 changed files with 66 additions and 77 deletions

View file

@ -1,7 +0,0 @@
test:
script:
- apt-get update
- apt-get install -yy python git
- git clone https://github.com/YunoHost/package_linter
- pip install report
- python package_linter/package_linter.py .

View file

@ -1,7 +0,0 @@
language: python
install: ""
python:
- "3.5"
script:
- git clone https://github.com/YunoHost/package_linter
- python package_linter/package_linter.py .

View file

@ -4,7 +4,6 @@
path="/path" path="/path"
is_public=1 is_public=1
password="password" password="password"
port="9000"
; Checks ; Checks
pkg_linter=1 pkg_linter=1
setup_sub_dir=1 setup_sub_dir=1

View file

@ -6,7 +6,7 @@ After=network.target
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__ WorkingDirectory=__FINALPATH__/
Environment="PATH=__ENV_PATH__" Environment="PATH=__ENV_PATH__"
Environment="THELOUNGE_HOME=/home/yunohost.app/__APP__/" Environment="THELOUNGE_HOME=/home/yunohost.app/__APP__/"
Environment="NODE_ENV=production" Environment="NODE_ENV=production"

View file

@ -24,7 +24,7 @@ app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
config_path=$(ynh_app_setting_get --app=$app --key=config_path) datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# DECLARE DATA AND CONF FILES TO BACKUP # DECLARE DATA AND CONF FILES TO BACKUP
@ -53,7 +53,7 @@ ynh_backup --src_path="/etc/systemd/system/$app.service"
# BACKUP CONFIG # BACKUP CONFIG
#================================================= #=================================================
ynh_backup --src_path="$config_path" ynh_backup --src_path="$datadir"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -88,6 +88,10 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# 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 ynh_setup_source --dest_dir=$final_path
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
@ -96,6 +100,21 @@ ynh_script_progression --message="Configuring NGINX web server..."
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
#=================================================
# CREATE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Creating a data directory..."
datadir=/home/yunohost.app/$app
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
mkdir -p $datadir
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:www-data "$datadir"
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
#================================================= #=================================================
@ -103,8 +122,6 @@ ynh_add_nginx_config
#================================================= #=================================================
ynh_script_progression --message="Modifying a config file..." ynh_script_progression --message="Modifying a config file..."
mkdir -p /home/yunohost.app/$app
ynh_add_config --template="../conf/config.js" --destination="$config_path/config.js" ynh_add_config --template="../conf/config.js" --destination="$config_path/config.js"
#================================================= #=================================================
@ -114,7 +131,7 @@ ynh_script_progression --message="Installing The Lounge..."
pushd $final_path pushd $final_path
ynh_use_nodejs ynh_use_nodejs
yarn install ynh_exec_warn_less NODE_ENV=production yarn install
ynh_exec_warn_less NODE_ENV=production yarn build ynh_exec_warn_less NODE_ENV=production yarn build
popd popd
@ -128,17 +145,6 @@ ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path" --t
ynh_add_systemd_config ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Securing files and directories..."
# Set permissions to app files
chown -R $app: $final_path
chown -R $app: $config_path
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
@ -159,8 +165,11 @@ ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_
#================================================= #=================================================
ynh_script_progression --message="Configuring permissions..." ynh_script_progression --message="Configuring permissions..."
# Make app public if necessary or protect it # Make app public if necessary
[ $is_public -eq 0 ] || ynh_permission_update --permission="main" --add="visitors" if [ $is_public -eq 1 ]
then
ynh_permission_update --permission="main" --add="visitors"
fi
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX

View file

@ -19,7 +19,7 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port) port=$(ynh_app_setting_get --app=$app --key=port)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
config_path=$(ynh_app_setting_get --app=$app --key=config_path) datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
@ -73,7 +73,7 @@ ynh_remove_nginx_config
#================================================= #=================================================
ynh_script_progression --message="Removing the config file..." ynh_script_progression --message="Removing the config file..."
ynh_secure_remove --file="$config_path" ynh_secure_remove --file="$datadir"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION

View file

@ -29,7 +29,7 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
config_path=$(ynh_app_setting_get --app=$app --key=config_path) datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
@ -65,21 +65,22 @@ ynh_script_progression --message="Restoring $app main directory..."
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$final_path"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#================================================= #=================================================
# RESTORE THE CONFIG # RESTORE THE CONFIG
#================================================= #=================================================
ynh_script_progression --message="Restoring the config path..." ynh_script_progression --message="Restoring the config path..."
ynh_restore_file --origin_path="$config_path" ynh_restore_file --origin_path="$datadir" --not_mandatory
#================================================= mkdir -p $datadir
# RESTORE USER RIGHTS
#=================================================
ynh_script_progression --message="Restoring user rights..."
# Restore permissions to app files chmod 750 "$datadir"
chown -R $app: $final_path chmod -R o-rwx "$datadir"
chown -R $app: $config_path chown -R $app:www-data "$datadir"
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION

View file

@ -19,7 +19,7 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
config_path=$(ynh_app_setting_get --app=$app --key=config_path) datadir=$(ynh_app_setting_get --app=$app --key=datadir)
port=$(ynh_app_setting_get --app=$app --key=port) port=$(ynh_app_setting_get --app=$app --key=port)
#================================================= #=================================================
@ -29,6 +29,21 @@ ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed) 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)..."
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
@ -40,11 +55,11 @@ if [ -z "$final_path" ]; then
ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_app_setting_set --app=$app --key=final_path --value=$final_path
fi fi
# If config_path doesn't exist, create it # If datadir doesn't exist, create it
if [ -z "$config_path" ]; then if [ -z "$datadir" ]; then
config_path=/home/yunohost.app/$app datadir=/home/yunohost.app/$app
mkdir -p /home/yunohost.app/$app mkdir -p /home/yunohost.app/$app
ynh_app_setting_set --app=$app --key=config_path --value=$config_path ynh_app_setting_set --app=$app --key=datadir --value=$datadir
fi fi
# Cleaning legacy permissions # Cleaning legacy permissions
@ -54,21 +69,6 @@ if ynh_legacy_permissions_exists; then
ynh_app_setting_delete --app=$app --key=is_public ynh_app_setting_delete --app=$app --key=is_public
fi fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up $app before upgrading (may take a while)..."
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
#================================================= #=================================================
@ -100,6 +100,11 @@ then
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$final_path"
fi fi
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
chown -R $app:www-data $datadir
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
@ -130,7 +135,7 @@ then
ynh_script_progression --message="Upgrading the lounge..." ynh_script_progression --message="Upgrading the lounge..."
pushd $final_path pushd $final_path
ynh_use_nodejs ynh_use_nodejs
yarn install ynh_exec_warn_less NODE_ENV=production yarn install
ynh_exec_warn_less NODE_ENV=production yarn build ynh_exec_warn_less NODE_ENV=production yarn build
popd popd
fi fi
@ -152,17 +157,6 @@ ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path" --t
ynh_add_systemd_config ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Securing files and directories..."
# Set permissions on app files
chown -R $app: $final_path
chown -R $app: $config_path
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================