mirror of
https://github.com/YunoHost-Apps/baikal_ynh.git
synced 2024-09-03 18:16:11 +02:00
[fix] Harden set options in scripts and remove silently
This commit is contained in:
parent
f38ed83384
commit
e065a1afc2
5 changed files with 35 additions and 25 deletions
|
@ -1,8 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Retrieve arguments
|
||||
backup_dir=$1
|
||||
app=$2
|
||||
# Exit on command errors and treat unset variables as an error
|
||||
set -eu
|
||||
|
||||
# Retrieve app id
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Set app specific variables
|
||||
dbname=$app
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
# Exit on command errors and treat unset variables as an error
|
||||
set -eu
|
||||
|
||||
# Retrieve app id
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$1
|
||||
path=${2%/}
|
||||
password=$3
|
||||
app=${!#}
|
||||
|
||||
# Load common variables and helpers
|
||||
source ./_common.sh
|
||||
. ./_common.sh
|
||||
|
||||
# Set app specific variables
|
||||
dbname=$app
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Retrieve arguments
|
||||
app=${!#}
|
||||
# Retrieve app id
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Load common variables and helpers
|
||||
source ./_common.sh
|
||||
. ./_common.sh
|
||||
|
||||
# Set app specific variables
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
|
||||
# Drop MySQL database and user
|
||||
ynh_mysql_drop_db $dbname || true
|
||||
ynh_mysql_drop_user $dbuser || true
|
||||
ynh_mysql_drop_db "$dbname" 2>/dev/null || true
|
||||
ynh_mysql_drop_user "$dbuser" 2>/dev/null || true
|
||||
|
||||
# Retrieve domain from app settings
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
|
||||
# Delete app directory and configurations
|
||||
sudo rm -rf "/var/www/${app}"
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Retrieve arguments
|
||||
backup_dir=$1
|
||||
app=$2
|
||||
# Exit on command errors and treat unset variables as an error
|
||||
set -eu
|
||||
|
||||
# Set app specific variables
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
# Retrieve app id
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Source app helpers
|
||||
. /usr/share/yunohost/helpers
|
||||
|
@ -16,6 +14,10 @@ domain=$(ynh_app_setting_get "$app" domain)
|
|||
path=$(ynh_app_setting_get "$app" path)
|
||||
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||
|
||||
# Set app specific variables
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
|
||||
# Check domain/path availability
|
||||
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
||||
|| exit 1
|
||||
|
|
|
@ -1,20 +1,23 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -u
|
||||
# Exit on command errors and treat unset variables as an error
|
||||
set -eu
|
||||
|
||||
# Retrieve app id
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Load common variables and helpers
|
||||
. ./_common.sh
|
||||
|
||||
# Set app specific variables
|
||||
app=${!#}
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
|
||||
# Retrieve arguments
|
||||
# Retrieve app settings
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
path=$(ynh_app_setting_get "$app" path)
|
||||
path=${path%/}
|
||||
|
||||
# Set app specific variables
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
|
||||
# Check destination directory
|
||||
DESTDIR="/var/www/$app"
|
||||
[[ ! -d $DESTDIR ]] && ynh_die \
|
||||
|
|
Loading…
Add table
Reference in a new issue