2017-03-03 21:26:30 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2017-03-05 17:40:21 +01:00
|
|
|
# TODO: enable with fix of https://github.com/YunoHost/yunohost/pull/246
|
|
|
|
# source .hfunctions
|
|
|
|
|
|
|
|
# TODO: remove with fix of https://github.com/YunoHost/yunohost/pull/246
|
|
|
|
install_dependencies() {
|
2020-10-22 21:15:55 +02:00
|
|
|
apt-get install --quiet --yes python-msgpack python-gevent
|
2017-03-05 17:40:21 +01:00
|
|
|
}
|
|
|
|
|
2017-11-15 20:50:51 +01:00
|
|
|
is_app_restorable() {
|
|
|
|
local -r domain=$1
|
|
|
|
local -r path=$2
|
|
|
|
local -r deploy_path=$3
|
|
|
|
|
|
|
|
ynh_webpath_available $domain $path \
|
|
|
|
|| ynh_die "Path not available: ${domain}${path}"
|
|
|
|
|
|
|
|
test ! -d $deploy_path \
|
|
|
|
|| ynh_die "There is already a directory: $deploy_path"
|
|
|
|
}
|
|
|
|
|
2017-03-03 21:26:30 +01:00
|
|
|
main() {
|
2017-11-15 19:19:00 +01:00
|
|
|
ynh_abort_if_errors
|
|
|
|
|
2017-03-03 21:26:30 +01:00
|
|
|
local app=$YNH_APP_INSTANCE_NAME
|
2017-11-15 20:50:51 +01:00
|
|
|
local domain=$(ynh_app_setting_get $app domain)
|
|
|
|
local path=$(ynh_app_setting_get $app path)
|
2017-03-03 21:26:30 +01:00
|
|
|
local deploy_path=$(ynh_app_setting_get $app deploy_path)
|
|
|
|
local symlink_to_deploy_path=$(ynh_app_setting_get $app symlink_to_deploy_path)
|
|
|
|
local nginx_config_file=$( ynh_app_setting_get $app nginx_config_file )
|
|
|
|
local systemd_service_name=$( ynh_app_setting_get $app systemd_service_name )
|
|
|
|
local systemd_service_file=$( ynh_app_setting_get $app systemd_service_file )
|
|
|
|
local user=$( ynh_app_setting_get $app user )
|
|
|
|
local user_zeronet_dir=$( ynh_app_setting_get $app user_zeronet_dir )
|
|
|
|
|
|
|
|
local url=$(ynh_app_setting_get $app url)
|
|
|
|
|
2017-11-15 20:50:51 +01:00
|
|
|
is_app_restorable $domain $path $deploy_path
|
2017-03-05 17:40:21 +01:00
|
|
|
|
2017-11-15 20:50:51 +01:00
|
|
|
install_dependencies
|
2017-03-03 21:26:30 +01:00
|
|
|
|
2020-10-22 21:15:55 +02:00
|
|
|
cp -a "./sources" $deploy_path
|
|
|
|
ln --symbolic --force $deploy_path $symlink_to_deploy_path
|
|
|
|
chown $user: -LR $symlink_to_deploy_path
|
|
|
|
chown $user: -h $symlink_to_deploy_path
|
2017-03-03 21:26:30 +01:00
|
|
|
|
2020-10-22 21:15:55 +02:00
|
|
|
ynh_secure_remove $user_zeronet_dir
|
|
|
|
cp -aR "./conf/.zeronet" $user_zeronet_dir
|
|
|
|
chown -R $user: $user_zeronet_dir
|
2017-03-03 21:26:30 +01:00
|
|
|
|
2020-10-22 21:15:55 +02:00
|
|
|
cp -a "./conf/nginx.conf" $nginx_config_file
|
|
|
|
service nginx reload
|
2017-03-03 21:26:30 +01:00
|
|
|
|
2020-10-22 21:15:55 +02:00
|
|
|
cp -a "./conf/${systemd_service_name}" $systemd_service_file
|
|
|
|
systemctl restart $systemd_service_name
|
2017-03-03 21:26:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
main
|