From 8b7594a1188c9782953ff70a8795e597757063ca Mon Sep 17 00:00:00 2001 From: Jules Bertholet Date: Sat, 17 Apr 2021 21:40:36 -0400 Subject: [PATCH] Minor improvements to scripts --- scripts/_common.sh | 26 ++++++++++++++++++++++---- scripts/install | 15 +++------------ scripts/restore | 6 +----- scripts/upgrade | 15 +++------------ 4 files changed, 29 insertions(+), 33 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index a2f9883..9686c57 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -11,6 +11,28 @@ pkg_dependencies="acl nim redis-server libsass-dev" # PERSONAL HELPERS #================================================= +function build_nitter { + pushd "$final_path" || ynh_die + chown -R $app:$app $final_path + sudo -u $app env "PATH=/opt/yunohost/$app/nim-installation/bin:$(sudo -u $app sh -c 'echo $PATH')" nimble build -d:release -y + sudo -u $app env "PATH=/opt/yunohost/$app/nim-installation/bin:$(sudo -u $app sh -c 'echo $PATH')" nimble scss -y + mkdir -p $final_path/tmp + chown -R root:root $final_path + popd || ynh_die +} + +function set_permissions { + chown -R root:$app $final_path + chown -R $app:$app $final_path/tmp + chmod -R g=u,g-w,o-rwx $final_path + setfacl -n -m u:www-data:--x $final_path + setfacl -nR -m u:www-data:r-x -m d:u:www-data:r-x $final_path/public +} + +#================================================= +# EXPERIMENTAL HELPERS +#================================================= + # Check the architecture # # example: architecture=$(ynh_detect_arch) @@ -35,10 +57,6 @@ ynh_detect_arch(){ echo $architecture } -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - #================================================= # FUTURE OFFICIAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index d64a080..cfdc825 100755 --- a/scripts/install +++ b/scripts/install @@ -132,13 +132,8 @@ usermod -d $final_path $app 2>&1 # COMPILE NITTER #================================================= ynh_script_progression --message="Compiling Nitter..." --weight=30 -pushd "$final_path" || ynh_die - chown -R $app:$app $final_path - sudo -u $app "PATH=/opt/yunohost/$app/nim-installation/bin:$(sudo -u $app sh -c 'echo $PATH')" $final_path/nim-installation/bin/nimble build -d:release -y - sudo -u $app "PATH=/opt/yunohost/$app/nim-installation/bin:$(sudo -u $app sh -c 'echo $PATH')" $final_path/nim-installation/bin/nimble scss -y - mkdir -p $final_path/tmp - chown -R root:root $final_path -popd || ynh_die + +build_nitter #================================================= # SETUP SYSTEMD @@ -159,11 +154,7 @@ ynh_add_config --template="nitter.conf" --destination="$final_path/nitter.conf" # SECURE FILES AND DIRECTORIES #================================================= # Set permissions to app files -chown -R root:$app $final_path -chown -R $app:$app $final_path/tmp -chmod -R g=u,g-w,o-rwx $final_path -setfacl -n -m user:www-data:rx $final_path -setfacl -n -R -m user:www-data:rx -m default:user:www-data:rx $final_path/public +set_permissions #================================================= # INTEGRATE SERVICE IN YUNOHOST diff --git a/scripts/restore b/scripts/restore index bca195a..ee2bfa5 100755 --- a/scripts/restore +++ b/scripts/restore @@ -78,11 +78,7 @@ ynh_install_app_dependencies $pkg_dependencies #================================================= # Restore permissions on app files -chown -R root:$app $final_path -chown -R $app:$app $final_path/tmp -chmod -R g=u,g-w,o-rwx $final_path -setfacl -n -m user:www-data:rx $final_path -setfacl -n -R -m user:www-data:rx -m default:user:www-data:rx $final_path/public +set_permissions #================================================= # SPECIFIC RESTORATION diff --git a/scripts/upgrade b/scripts/upgrade index f74027d..22275db 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -106,13 +106,8 @@ usermod -d $final_path $app 2>&1 # COMPILE NITTER #================================================= ynh_script_progression --message="Compiling Nitter..." --weight=30 -pushd "$final_path" || ynh_die - chown -R $app:$app $final_path - sudo -u $app "PATH=/opt/yunohost/$app/nim-installation/bin:$(sudo -u $app sh -c 'echo $PATH')" $final_path/nim-installation/bin/nimble build -d:release -y - sudo -u $app "PATH=/opt/yunohost/$app/nim-installation/bin:$(sudo -u $app sh -c 'echo $PATH')" $final_path/nim-installation/bin/nimble scss -y - mkdir -p $final_path/tmp - chown -R root:root $final_path -popd || ynh_die + +build_nitter #================================================= # SETUP SYSTEMD @@ -134,11 +129,7 @@ ynh_add_config --template="nitter.conf" --destination="$final_path/nitter.conf" #================================================= # Set permissions on app files -chown -R root:$app $final_path -chown -R $app:$app $final_path/tmp -chmod -R g=u,g-w,o-rwx $final_path -setfacl -n -m user:www-data:rx $final_path -setfacl -n -R -m user:www-data:rx -m default:user:www-data:rx $final_path/public +set_permissions #================================================= # INTEGRATE SERVICE IN YUNOHOST #=================================================