mirror of
https://github.com/YunoHost-Apps/coin_ynh.git
synced 2024-09-03 18:16:26 +02:00
[enh] Upgrade script
This commit is contained in:
parent
be6e44ce75
commit
c9da4dd899
4 changed files with 119 additions and 4 deletions
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_URL=https://code.ffdn.org/FFDN/coin/archive/87a63df9409728e402301690a16aae2ad693c7ff.tar.gz
|
SOURCE_URL=https://code.ffdn.org/FFDN/coin/archive/b746cf1059cc3308e2e9e197a5e023522bf184ea.tar.gz
|
||||||
SOURCE_FILENAME=coin-2017-04-08.tar.gz
|
SOURCE_FILENAME=coin-2017-07-31.tar.gz
|
||||||
SOURCE_FORMAT=tar.gz
|
SOURCE_FORMAT=tar.gz
|
||||||
SOURCE_SUM=be9c152a35bc45c14cb80bfb9d6912ecfaab001a669dc56e8a3ace45c199612c
|
SOURCE_SUM=de3807acef0069043be5376860e8bbabbb4cb4697778d37a031aa15ccfbae2dc
|
||||||
SOURCE_SUM_PRG=sha256sum
|
SOURCE_SUM_PRG=sha256sum
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">> 2.5.0"
|
"yunohost": ">> 2.5.0"
|
||||||
},
|
},
|
||||||
"version": "20170408",
|
"version": "20170731",
|
||||||
"multi_instance": "false",
|
"multi_instance": "false",
|
||||||
"services": [
|
"services": [
|
||||||
"nginx"
|
"nginx"
|
||||||
|
|
|
@ -1,3 +1,21 @@
|
||||||
|
|
||||||
|
log() {
|
||||||
|
echo "${1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
info() {
|
||||||
|
log "[INFO] ${1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
warn() {
|
||||||
|
log "[WARN] ${1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
err() {
|
||||||
|
log "[ERR] ${1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#======================================================================
|
#======================================================================
|
||||||
# data/helpers.d/package
|
# data/helpers.d/package
|
||||||
#======================================================================
|
#======================================================================
|
||||||
|
@ -170,3 +188,54 @@ ynh_setup_source () {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ynh_exit_properly () {
|
||||||
|
exit_code=$?
|
||||||
|
if [ "$exit_code" -eq 0 ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
trap '' EXIT
|
||||||
|
set +eu
|
||||||
|
echo -e "\e[91m \e[1m"
|
||||||
|
err "$app script has encountered an error."
|
||||||
|
|
||||||
|
if type -t CLEAN_SETUP > /dev/null; then
|
||||||
|
CLEAN_SETUP
|
||||||
|
fi
|
||||||
|
|
||||||
|
ynh_die
|
||||||
|
}
|
||||||
|
|
||||||
|
# Activate signal capture
|
||||||
|
# Exit if a command fail, and if a variable is used unset.
|
||||||
|
# Capturing exit signals on shell script
|
||||||
|
#
|
||||||
|
# example: CLEAN_SETUP () {
|
||||||
|
# # Clean residual file un remove by remove script
|
||||||
|
# }
|
||||||
|
# ynh_trap_on
|
||||||
|
ynh_trap_on () {
|
||||||
|
set -eu
|
||||||
|
trap ynh_exit_properly EXIT # Capturing exit signals on shell script
|
||||||
|
}
|
||||||
|
|
||||||
|
ynh_read_json () {
|
||||||
|
sudo python3 -c "import sys, json;print(json.load(open('$1'))['$2'])"
|
||||||
|
}
|
||||||
|
|
||||||
|
ynh_read_manifest () {
|
||||||
|
if [ -f '../manifest.json' ] ; then
|
||||||
|
ynh_read_json '../manifest.json' "$1"
|
||||||
|
else
|
||||||
|
ynh_read_json '../settings/manifest.json' "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
ynh_exit_if_up_to_date () {
|
||||||
|
if [ "${version}" = "${last_version}" ]; then
|
||||||
|
info "Up-to-date, nothing to do"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1 +1,47 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
source common.sh
|
||||||
|
source future.sh
|
||||||
|
|
||||||
|
export app=$YNH_APP_INSTANCE_NAME
|
||||||
|
user=$app
|
||||||
|
|
||||||
|
export domain=$(ynh_app_setting_get $app domain)
|
||||||
|
export path=$(ynh_app_setting_get $app path)
|
||||||
|
export admin=$(ynh_app_setting_get $app admin)
|
||||||
|
export email=$(ynh_app_setting_get $app email)
|
||||||
|
export isp_name=$(ynh_app_setting_get $app isp_name)
|
||||||
|
export isp_site=$(ynh_app_setting_get $app isp_site)
|
||||||
|
export secret=$(ynh_app_setting_get $app secret)
|
||||||
|
version=$(ynh_read_json "/etc/yunohost/apps/$app/manifest.json" 'version' 2> /dev/null || echo '20170408')
|
||||||
|
last_version=$(ynh_read_manifest 'version')
|
||||||
|
|
||||||
|
ynh_exit_if_up_to_date
|
||||||
|
ynh_check_var "$app" "app name not set"
|
||||||
|
ynh_user_exists "$admin" || err "User does not exist: $admin"
|
||||||
|
ynh_normalize_url_path "$path"
|
||||||
|
|
||||||
|
#if [ "${version}" = "20170408" ]; then
|
||||||
|
#fi
|
||||||
|
|
||||||
|
# Copy files to the right place
|
||||||
|
final_path=/opt/$app
|
||||||
|
ynh_setup_source $final_path
|
||||||
|
|
||||||
|
set +o nounset
|
||||||
|
source $final_path/venv/bin/activate
|
||||||
|
set -o nounset
|
||||||
|
$final_path/venv/bin/pip install -r $final_path/requirements.txt
|
||||||
|
|
||||||
|
# Set permissions
|
||||||
|
sudo useradd $app -d $final_path || echo "User already exists"
|
||||||
|
sudo chown -R $app:www-data $final_path
|
||||||
|
|
||||||
|
pushd $final_path
|
||||||
|
$final_path/venv/bin/python manage.py migrate --noinput
|
||||||
|
$final_path/venv/bin/python manage.py collectstatic --noinput
|
||||||
|
popd
|
||||||
|
|
||||||
|
# Set permissions to directory
|
||||||
|
sudo chown $app:www-data -R $final_path
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue