mirror of
https://github.com/YunoHost-Apps/dont-code_ynh.git
synced 2024-09-03 18:26:34 +02:00
regroup code into common.sh
This commit is contained in:
parent
dd69364d91
commit
51e94e2719
5 changed files with 30 additions and 37 deletions
|
@ -22,13 +22,31 @@ ynh_java="/usr/lib/jvm/java-${java_version}-openjdk-amd64/bin/java"
|
||||||
# PERSONAL HELPERS
|
# PERSONAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
append_uri() {
|
append_uri() {
|
||||||
local return="";
|
local return="";
|
||||||
if [[ $1 == */ ]]; then
|
if [[ $1 == */ ]]; then
|
||||||
return=$1$2;
|
return=$1$2;
|
||||||
else
|
else
|
||||||
return=$1/$2
|
return=$1/$2
|
||||||
fi
|
fi
|
||||||
echo "$return";
|
echo "$return";
|
||||||
|
}
|
||||||
|
|
||||||
|
_install_restart_script_and_sudoers() {
|
||||||
|
# Enable restarting of services from ssh
|
||||||
|
ynh_add_config --template="restart-services.sh" --destination="$install_dir/restart-services.sh"
|
||||||
|
chown "$app:$app" "$install_dir/restart-services.sh"
|
||||||
|
chmod o-rwx,gu=rwx "$install_dir/restart-services.sh"
|
||||||
|
|
||||||
|
# Add sudoers file for this specific command
|
||||||
|
ynh_add_config --template="dont-code-sudoers" --destination="/etc/sudoers.d/$app-sudoers"
|
||||||
|
chown root:root "/etc/sudoers.d/$app-sudoers"
|
||||||
|
chmod o-rwx,gu=r "/etc/sudoers.d/$app-sudoers"
|
||||||
|
}
|
||||||
|
|
||||||
|
_remove_restart_script_and_sudoers() {
|
||||||
|
if [ -f "/etc/sudoers.d/$app-sudoers" ]; then
|
||||||
|
ynh_secure_remove --file="/etc/sudoers.d/$app-sudoers"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -66,15 +66,7 @@ if [ -n "$public_key" ]; then
|
||||||
chmod 700 "$install_dir/.ssh"
|
chmod 700 "$install_dir/.ssh"
|
||||||
chmod 600 "$install_dir/.ssh/authorized_keys"
|
chmod 600 "$install_dir/.ssh/authorized_keys"
|
||||||
|
|
||||||
# Enable restarting of services from ssh
|
_install_restart_script_and_sudoers
|
||||||
ynh_add_config --template="restart-services.sh" --destination="$install_dir/restart-services.sh"
|
|
||||||
chown "$app:$app" "$install_dir/restart-services.sh"
|
|
||||||
chmod o-rwx,gu=rwx "$install_dir/restart-services.sh"
|
|
||||||
|
|
||||||
# Add sudoers file for this specific command
|
|
||||||
ynh_add_config --template="dont-code-sudoers" --destination="/etc/sudoers.d/$app-sudoers"
|
|
||||||
chown root:root "/etc/sudoers.d/$app-sudoers"
|
|
||||||
chmod o-rwx,gu=r "/etc/sudoers.d/$app-sudoers"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -42,9 +42,7 @@ done
|
||||||
# Remove mongo itself if not used anymore
|
# Remove mongo itself if not used anymore
|
||||||
ynh_remove_mongo
|
ynh_remove_mongo
|
||||||
|
|
||||||
if [ -f "/etc/sudoers.d/$app-sudoers" ]; then
|
_remove_restart_script_and_sudoers
|
||||||
ynh_secure_remove --file="/etc/sudoers.d/$app-sudoers"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Remove the log files
|
# Remove the log files
|
||||||
ynh_secure_remove --file="/var/log/$app"
|
ynh_secure_remove --file="/var/log/$app"
|
||||||
|
|
|
@ -48,14 +48,7 @@ if [ -n "$public_key" ]; then
|
||||||
chmod 700 "$install_dir/.ssh"
|
chmod 700 "$install_dir/.ssh"
|
||||||
chmod 600 "$install_dir/.ssh/authorized_keys"
|
chmod 600 "$install_dir/.ssh/authorized_keys"
|
||||||
|
|
||||||
# Enable restart of services for the dont-code user
|
_install_restart_script_and_sudoers
|
||||||
chown "$app:$app" "$install_dir/restart-services.sh"
|
|
||||||
chmod o-rwx,gu=rwx "$install_dir/restart-services.sh"
|
|
||||||
|
|
||||||
# Add sudoers file for this specific command
|
|
||||||
ynh_restore_file --origin_path="/etc/sudoers.d/$app-sudoers"
|
|
||||||
chown root:root "/etc/sudoers.d/$app-sudoers"
|
|
||||||
chmod o-rwx,gu=r "/etc/sudoers.d/$app-sudoers"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -76,6 +69,7 @@ ynh_mongo_setup_db --db_user=$db_user --db_name=${MONGO_DB_LIST[0]} --db_pwd=$db
|
||||||
for db_name in "${MONGO_DB_LIST[@]}"; do
|
for db_name in "${MONGO_DB_LIST[@]}"; do
|
||||||
ynh_mongo_restore_db --database="$db_name" < "./dump-${db_name}.bson"
|
ynh_mongo_restore_db --database="$db_name" < "./dump-${db_name}.bson"
|
||||||
done
|
done
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE SYSTEM CONFIGURATIONS
|
# RESTORE SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -91,16 +91,7 @@ chown "$app:www-data" "$data_dir"
|
||||||
|
|
||||||
if [ -n "$public_key" ]; then
|
if [ -n "$public_key" ]; then
|
||||||
ynh_script_progression --message="Upgrading ssh access for dev..." --weight=1
|
ynh_script_progression --message="Upgrading ssh access for dev..." --weight=1
|
||||||
|
_install_restart_script_and_sudoers
|
||||||
# Enable restarting of services from ssh
|
|
||||||
ynh_add_config --template="restart-services.sh" --destination="$install_dir/restart-services.sh"
|
|
||||||
chown "$app:$app" "$install_dir/restart-services.sh"
|
|
||||||
chmod o-rwx,gu=rwx "$install_dir/restart-services.sh"
|
|
||||||
|
|
||||||
# Add sudoers file for this specific command
|
|
||||||
ynh_add_config --template="dont-code-sudoers" --destination="/etc/sudoers.d/$app-sudoers"
|
|
||||||
chown root:root "/etc/sudoers.d/$app-sudoers"
|
|
||||||
chmod o-rwx,gu=r "/etc/sudoers.d/$app-sudoers"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Reference in a new issue