From 8d7ac89845d8d8a2ba0e891bdfb31ed9c1b2e218 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 13 Jun 2021 15:49:55 +0200 Subject: [PATCH] Fix --- conf/{app.src => amd64.src} | 2 +- conf/nginx.conf | 16 +++++++--- scripts/_common.sh | 61 +++++++++++++------------------------ scripts/install | 19 ++++++------ 4 files changed, 44 insertions(+), 54 deletions(-) rename conf/{app.src => amd64.src} (91%) diff --git a/conf/app.src b/conf/amd64.src similarity index 91% rename from conf/app.src rename to conf/amd64.src index 3729d4d..53b50be 100644 --- a/conf/app.src +++ b/conf/amd64.src @@ -2,6 +2,6 @@ SOURCE_URL=https://github.com/muesli/beehive/releases/download/v0.4.0/beehive_0. SOURCE_SUM=f1959bc2f7c19d4ec8eaabc7b78492836afcc3bcd75d034854e66607efa9efab SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true +SOURCE_IN_SUBDIR=false SOURCE_FILENAME= SOURCE_EXTRACT=true diff --git a/conf/nginx.conf b/conf/nginx.conf index 86c09ea..a6416a0 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -6,9 +6,15 @@ location __PATH__/ { rewrite ^ https://$server_name$request_uri? permanent; } -proxy_pass http://localhost:__PORT__; - - - # Include SSOWAT user panel. - include conf.d/yunohost_panel.conf.inc; + proxy_pass https://127.0.0.1:__PORT__; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Host $server_name; + + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; } diff --git a/scripts/_common.sh b/scripts/_common.sh index 7873157..5fee926 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -3,7 +3,7 @@ #================================================= # COMMON VARIABLES #================================================= -GO_VERSION=1.16 + # dependencies used by the app pkg_dependencies="wget" @@ -11,45 +11,28 @@ pkg_dependencies="wget" # PERSONAL HELPERS #================================================= -if [ -n "$(uname -m | grep arm64)" ] || [ -n "$(uname -m | grep aarch64)" ]; then - architecture="arm64" -elif [ -n "$(uname -m | grep 64)" ]; then - architecture="amd64" -else - ynh_die "Unable to detect your achitecture, please open a bug describing \ - your hardware and the result of the command \"uname -m\"." 1 -fi +# Check the architecture +# +# example: architecture=$(ynh_detect_arch) +# +# usage: ynh_detect_arch +# +# Requires YunoHost version 2.2.4 or higher. -ynh_smart_mktemp () { - local min_size="${1:-300}" - # Transform the minimum size from megabytes to kilobytes - min_size=$(( $min_size * 1024 )) - - # Check if there's enough free space in a directory - is_there_enough_space () { - local free_space=$(df --output=avail "$1" | sed 1d) - test $free_space -ge $min_size - } - - if is_there_enough_space /tmp; then - local tmpdir=/tmp - elif is_there_enough_space /var; then - local tmpdir=/var - elif is_there_enough_space /; then - local tmpdir=/ - elif is_there_enough_space /home; then - local tmpdir=/home +ynh_detect_arch(){ + local architecture + if [ -n "$(uname -m | grep arm64)" ] || [ -n "$(uname -m | grep aarch64)" ]; then + architecture="arm64" + elif [ -n "$(uname -m | grep 64)" ]; then + architecture="amd64" + elif [ -n "$(uname -m | grep 86)" ]; then + architecture="386" + elif [ -n "$(uname -m | grep armv7)" ]; then + architecture="arm7" + elif [ -n "$(uname -m | grep armv6)" ]; then + architecture="arm6" else - ynh_die "Insufficient free space to continue..." + architecture="unknown" fi - - echo "$(mktemp --directory --tmpdir="$tmpdir")" + echo $architecture } - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - -#================================================= -# FUTURE OFFICIAL HELPERS -#================================================= diff --git a/scripts/install b/scripts/install index 6dc8d5e..f35da6e 100755 --- a/scripts/install +++ b/scripts/install @@ -27,6 +27,7 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url="/" admin=$YNH_APP_ARG_ADMIN +architecture=$(ynh_detect_arch) app=$YNH_APP_INSTANCE_NAME @@ -61,13 +62,6 @@ ynh_script_progression --message="Finding an available port..." --weight=1 port=$(ynh_find_port --port=8181) ynh_app_setting_set --app=$app --key=port --value=$port -#================================================= -# INSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Installing dependencies..." --weight=1 - -ynh_install_app_dependencies $pkg_dependencies - #================================================= # CREATE DEDICATED USER #================================================= @@ -76,6 +70,13 @@ ynh_script_progression --message="Configuring system user..." --weight=1 # Create a system user ynh_system_user_create --username=$app --home_dir="$final_path" +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Installing dependencies..." --weight=1 + +ynh_install_app_dependencies $pkg_dependencies + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -83,10 +84,10 @@ ynh_script_progression --message="Setting up source files..." --weight=1 ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$final_path" +ynh_setup_source --dest_dir="$final_path" --source_id="$architecture" chmod 750 "$final_path" -chmod -R o-rwx "$final_path" +#chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" #=================================================