1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/coin_ynh.git synced 2024-09-03 18:16:26 +02:00
coin_ynh/scripts/upgrade

76 lines
2.1 KiB
Text
Raw Normal View History

2017-04-09 11:05:39 +02:00
#!/bin/bash
2017-07-31 14:49:23 +02:00
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
2017-08-02 16:26:44 +02:00
# Install new dependencies
install_dependencies
2017-07-31 14:49:23 +02:00
# Copy files to the right place
final_path=/opt/$app
2017-08-02 16:26:44 +02:00
[ -L ${final_path}/coin ] || ynh_setup_source $final_path
2017-07-31 14:49:23 +02:00
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
2017-08-02 16:26:44 +02:00
useradd $app -d $final_path || echo "User already exists"
chown -R $app:www-data $final_path
2017-07-31 14:49:23 +02:00
pushd $final_path
2017-08-02 16:26:44 +02:00
if [ "${version}" = "20170731" ]; then
init_db
ynh_app_setting_delete $app mysqlpassword
$final_path/venv/bin/python manage.py dumpdata > /tmp/dump.json
cat >> /opt/$app/coin/settings_local.py <<EOF
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': '$db_name',
'USER': '$db_user',
'PASSWORD': '$db_pwd',
'HOST': '', # Empty for localhost through domain sockets
'PORT': '', # Empty for default
},
}
EOF
fi
2017-07-31 14:49:23 +02:00
$final_path/venv/bin/python manage.py migrate --noinput
2017-08-02 16:26:44 +02:00
if [ "${version}" = "20170731" ]; then
$final_path/venv/bin/python manage.py loaddata /tmp/dump.json
fi
2017-07-31 14:49:23 +02:00
$final_path/venv/bin/python manage.py collectstatic --noinput
popd
# Set permissions to directory
2017-08-02 16:26:44 +02:00
chown $app:www-data -R $final_path
2017-07-31 14:49:23 +02:00
2017-08-02 16:26:44 +02:00
[ -L ${final_path}/coin ] || service coin restart