mirror of
https://github.com/YunoHost-Apps/coin_ynh.git
synced 2024-09-03 18:16:26 +02:00
75 lines
2.1 KiB
Bash
75 lines
2.1 KiB
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
|
|
|
|
# Install new dependencies
|
|
install_dependencies
|
|
|
|
# Copy files to the right place
|
|
final_path=/opt/$app
|
|
[ -L ${final_path}/coin ] || 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
|
|
useradd $app -d $final_path || echo "User already exists"
|
|
chown -R $app:www-data $final_path
|
|
|
|
pushd $final_path
|
|
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
|
|
|
|
$final_path/venv/bin/python manage.py migrate --noinput
|
|
|
|
if [ "${version}" = "20170731" ]; then
|
|
$final_path/venv/bin/python manage.py loaddata /tmp/dump.json
|
|
fi
|
|
|
|
$final_path/venv/bin/python manage.py collectstatic --noinput
|
|
popd
|
|
|
|
# Set permissions to directory
|
|
chown $app:www-data -R $final_path
|
|
|
|
[ -L ${final_path}/coin ] || service coin restart
|