mirror of
https://github.com/YunoHost-Apps/grafana_ynh.git
synced 2024-09-03 20:36:29 +02:00
Choose port during install
This commit is contained in:
parent
cc61abbecc
commit
ac71922b54
6 changed files with 37 additions and 7 deletions
|
@ -5,6 +5,7 @@
|
|||
path="/path" (PATH)
|
||||
admin="john" (USER)
|
||||
is_public=1 (PUBLIC|public=1|private=0)
|
||||
port="3000" (PORT)
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_sub_dir=1
|
||||
|
@ -19,9 +20,9 @@
|
|||
wrong_path=1
|
||||
incorrect_path=1
|
||||
corrupt_source=0
|
||||
fail_download_source=0
|
||||
port_already_use=0
|
||||
final_path_already_use=0
|
||||
fail_download_source=0
|
||||
port_already_use=1
|
||||
final_path_already_use=0
|
||||
;;; Levels
|
||||
Level 1=auto
|
||||
Level 2=auto
|
||||
|
|
|
@ -3,7 +3,7 @@ location / {
|
|||
proxy_set_header X-Forwarded-Server $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-WEBAUTH-USER $remote_user;
|
||||
proxy_pass http://127.0.0.1:3000;
|
||||
proxy_pass http://127.0.0.1:YNH_WWW_PORT;
|
||||
proxy_http_version 1.1;
|
||||
proxy_pass_request_headers on;
|
||||
proxy_set_header Connection "keep-alive";
|
||||
|
@ -11,4 +11,4 @@ location / {
|
|||
|
||||
# Include SSOWAT user panel.
|
||||
include conf.d/yunohost_panel.conf.inc;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ location ~ YNH_WWW_PATH/(?<ndpath>.*) {
|
|||
proxy_pass_request_headers on;
|
||||
proxy_set_header Connection "keep-alive";
|
||||
proxy_store off;
|
||||
proxy_pass http://127.0.0.1:3000/$ndpath$is_args$args;
|
||||
proxy_pass http://127.0.0.1:YNH_WWW_PORT/$ndpath$is_args$args;
|
||||
|
||||
gzip on;
|
||||
gzip_proxied any;
|
||||
|
|
|
@ -43,6 +43,15 @@
|
|||
"example": "/grafana",
|
||||
"default": "/grafana"
|
||||
},
|
||||
{
|
||||
"name": "port",
|
||||
"ask": {
|
||||
"en": "Choose a port for your server. Let as default if you don't want to change it",
|
||||
"fr": "Entrez un port pour votre serveur. Laissez par défaut si vous ne voulez pas en changer"
|
||||
},
|
||||
"example": "3000",
|
||||
"default": "3000"
|
||||
},
|
||||
{
|
||||
"name": "admin",
|
||||
"type": "user",
|
||||
|
|
|
@ -102,4 +102,20 @@ EOF
|
|||
ynh_remove_app_dependencies () {
|
||||
dep_app=${app//_/-} # Replace all '_' by '-'
|
||||
ynh_package_autoremove ${dep_app}-ynh-deps # Remove the fake package and its dependencies if they not still used.
|
||||
}
|
||||
}
|
||||
|
||||
# Find a free port and return it
|
||||
#
|
||||
# example: port=$(ynh_find_port 8080)
|
||||
#
|
||||
# usage: ynh_find_port begin_port
|
||||
# | arg: begin_port - port to start to search
|
||||
ynh_find_port () {
|
||||
port=$1
|
||||
test -n "$port" || ynh_die "The argument of ynh_find_port must be a valid port."
|
||||
while netcat -z 127.0.0.1 $port # Check if the port is free
|
||||
do
|
||||
port=$((port+1)) # Else, pass to next port
|
||||
done
|
||||
echo $port
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ source ./_common.sh
|
|||
# Retrieve arguments
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path=$YNH_APP_ARG_PATH
|
||||
port=$(ynh_find_port $YNH_APP_ARG_PORT)
|
||||
admin=$YNH_APP_ARG_ADMIN
|
||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||
|
||||
|
@ -79,6 +80,8 @@ sudo systemctl start influxdb
|
|||
sudo cp ../conf/ldap.toml /etc/grafana
|
||||
|
||||
grafana_conf="/etc/grafana/grafana.ini"
|
||||
# Set final port
|
||||
sudo sed -i "/^\[server\]$/,/^\[/ s@;http_port = .*@http_port = $port@" $grafana_conf
|
||||
# Set final URL
|
||||
sudo sed -i "/^\[server\]$/,/^\[/ s@;root_url = .*@root_url = https://$domain$path@" $grafana_conf
|
||||
# Disable check for updates
|
||||
|
@ -138,6 +141,7 @@ else
|
|||
fi
|
||||
|
||||
sed -i "s@YNH_WWW_PATH@$path@g" $nginx_conf
|
||||
sed -i "s@YNH_WWW_PORT@$port@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
|
||||
|
|
Loading…
Reference in a new issue