mirror of
https://github.com/YunoHost-Apps/cesium_ynh.git
synced 2024-09-03 18:06:25 +02:00
43 lines
1.3 KiB
Bash
Executable file
43 lines
1.3 KiB
Bash
Executable file
#!/bin/bash
|
||
|
||
# Exit on command errors and treat unset variables as an error
|
||
set -eu
|
||
|
||
# Retrieve arguments
|
||
app=$YNH_APP_INSTANCE_NAME
|
||
domain=$YNH_APP_ARG_DOMAIN
|
||
path=$YNH_APP_ARG_PATH
|
||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||
version="0.1.18"
|
||
|
||
# Source YunoHost helpers
|
||
. /usr/share/yunohost/helpers
|
||
|
||
# Save app settings
|
||
ynh_app_setting_set "$app" is_public "$is_public"
|
||
|
||
# Check domain/path availability
|
||
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
||
|| ynh_die "Path not available: ${domain}${path}"
|
||
|
||
# Retrieve sources and install them
|
||
src_path=/var/www/$app
|
||
sudo mkdir -p $src_path
|
||
wget -nc --quiet https://github.com/duniter/cesium/releases/download/$version/cesium-web-$version.zip -P /tmp
|
||
sudo unzip -q /tmp/cesium-web-$version.zip -d $src_path
|
||
sudo chown -R www-data: $src_path
|
||
|
||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||
nginx_conf=../conf/nginx.conf
|
||
sed -i "s@YNH_WWW_PATH@$path@g" $nginx_conf
|
||
sed -i "s@YNH_WWW_ALIAS@$src_path/@g" $nginx_conf
|
||
sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||
|
||
# If app is public, add url to SSOWat conf as skipped_uris
|
||
if [[ $is_public -eq 1 ]]; then
|
||
# unprotected_uris allows SSO credentials to be passed anyway.
|
||
ynh_app_setting_set "$app" unprotected_uris "/"
|
||
fi
|
||
|
||
# Reload nginx service
|
||
sudo service nginx reload
|