mirror of
https://github.com/YunoHost-Apps/jupyterlab_ynh.git
synced 2024-09-03 19:26:35 +02:00
Format files
This commit is contained in:
parent
03ba0348c2
commit
5ed1002562
7 changed files with 94 additions and 108 deletions
|
@ -21,7 +21,7 @@
|
|||
"nginx"
|
||||
],
|
||||
"arguments": {
|
||||
"install" : [
|
||||
"install": [
|
||||
{
|
||||
"name": "domain",
|
||||
"type": "domain",
|
||||
|
@ -43,7 +43,7 @@
|
|||
},
|
||||
{
|
||||
"name": "admin",
|
||||
"type": "user",
|
||||
"type": "user",
|
||||
"ask": {
|
||||
"en": "Choose an admin user",
|
||||
"fr": "Choisissez l’administrateur"
|
||||
|
@ -70,4 +70,4 @@
|
|||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -74,7 +74,7 @@ config_jupyter_notebook() {
|
|||
#=================================================
|
||||
# CREATE A DEDICATED SYSTEMD CONFIG
|
||||
#=================================================
|
||||
add_systemd_config () {
|
||||
add_systemd_config() {
|
||||
ynh_print_info "Adding Jupyterlab as a service..."
|
||||
|
||||
sudo cp ../conf/systemd.service.default ../conf/systemd.service
|
||||
|
@ -139,41 +139,36 @@ setup_source() {
|
|||
src_format=${src_format:-tar.gz}
|
||||
src_format=$(echo "$src_format" | tr '[:upper:]' '[:lower:]')
|
||||
src_extract=${src_extract:-true}
|
||||
if [ "$src_filename" = "" ] ; then
|
||||
if [ "$src_filename" = "" ]; then
|
||||
src_filename="${src_id}.${src_format}"
|
||||
fi
|
||||
|
||||
if ! test -e "$final_path"
|
||||
then
|
||||
if ! test -e "$final_path"; then
|
||||
|
||||
local local_src="/opt/yunohost-apps-src/${YNH_APP_ID}/${src_filename}"
|
||||
|
||||
ynh_print_info "Downloading anaconda files (used by JupyterLab)..."
|
||||
ynh_print_info "Downloading anaconda files (used by JupyterLab)..."
|
||||
|
||||
|
||||
if test -e "$local_src"
|
||||
then # Use the local source file if it is present
|
||||
if test -e "$local_src"; then # Use the local source file if it is present
|
||||
cp $local_src $src_filename
|
||||
else # If not, download the source
|
||||
local out=`wget -nv -O $src_filename $src_url 2>&1` || ynh_print_err $out
|
||||
else # If not, download the source
|
||||
local out=$(wget -nv -O $src_filename $src_url 2>&1) || ynh_print_err $out
|
||||
fi
|
||||
|
||||
# Check the control sum
|
||||
echo "${src_sum} ${src_filename}" | ${src_sumprg} -c --status \
|
||||
|| ynh_die "Corrupt source"
|
||||
echo "${src_sum} ${src_filename}" | ${src_sumprg} -c --status ||
|
||||
ynh_die "Corrupt source"
|
||||
|
||||
ynh_print_info "Installing anaconda (used by JupyterLab)..."
|
||||
ynh_print_info "Installing anaconda (used by JupyterLab)..."
|
||||
|
||||
bash $src_filename -b -p $final_path
|
||||
fi
|
||||
|
||||
|
||||
export "PATH=$final_path/bin/:$PATH"
|
||||
|
||||
ynh_print_info "Installing JupyterLab..."
|
||||
|
||||
|
||||
if [ "$src_id" = "arm" ]
|
||||
then
|
||||
if [ "$src_id" = "arm" ]; then
|
||||
conda install jupyterlab=$jupyterlab_version notebook nodejs -y
|
||||
pip install jupyterhub jupyterhub-ldapauthenticator
|
||||
else
|
||||
|
@ -181,4 +176,4 @@ setup_source() {
|
|||
fi
|
||||
|
||||
npm install -g configurable-http-proxy
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,14 +54,12 @@ path_url="$new_path"
|
|||
#=================================================
|
||||
|
||||
change_domain=0
|
||||
if [ "$old_domain" != "$new_domain" ]
|
||||
then
|
||||
if [ "$old_domain" != "$new_domain" ]; then
|
||||
change_domain=1
|
||||
fi
|
||||
|
||||
change_path=0
|
||||
if [ "$old_path" != "$new_path" ]
|
||||
then
|
||||
if [ "$old_path" != "$new_path" ]; then
|
||||
change_path=1
|
||||
fi
|
||||
|
||||
|
@ -78,10 +76,9 @@ yunohost service stop jupyterlab
|
|||
#=================================================
|
||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||
|
||||
if [ $change_path -eq 1 ]
|
||||
then
|
||||
if [ $change_path -eq 1 ]; then
|
||||
ynh_print_info "Changing path..."
|
||||
|
||||
|
||||
# Make a backup of the original nginx config file if modified
|
||||
ynh_backup_if_checksum_is_different "$nginx_conf_path"
|
||||
# Set global variables for nginx helper
|
||||
|
@ -92,11 +89,10 @@ then
|
|||
fi
|
||||
|
||||
# Change the domain for nginx
|
||||
if [ $change_domain -eq 1 ]
|
||||
then
|
||||
if [ $change_domain -eq 1 ]; then
|
||||
ynh_print_info "Changing domain..."
|
||||
|
||||
# Delete file checksum for the old conf file location
|
||||
# Delete file checksum for the old conf file location
|
||||
ynh_delete_file_checksum "$nginx_conf_path"
|
||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||
# Store file checksum for the new config file location
|
||||
|
|
|
@ -12,81 +12,80 @@
|
|||
# | arg: -e, --length= - Length of the error log : Default : 20
|
||||
ynh_systemd_action() {
|
||||
|
||||
# Declare an array to define the options of this helper.
|
||||
declare -Ar args_array=( [n]=service_name= [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length= )
|
||||
local service_name
|
||||
local action
|
||||
local line_match
|
||||
local length
|
||||
local log_path
|
||||
local timeout
|
||||
# Declare an array to define the options of this helper.
|
||||
declare -Ar args_array=([n]=service_name= [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length=)
|
||||
local service_name
|
||||
local action
|
||||
local line_match
|
||||
local length
|
||||
local log_path
|
||||
local timeout
|
||||
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
|
||||
local service_name="${service_name:-$app}"
|
||||
local action=${action:-start}
|
||||
local log_path="${log_path:-/var/log/$service_name/$service_name.log}"
|
||||
local length=${length:-20}
|
||||
local timeout=${timeout:-300}
|
||||
local service_name="${service_name:-$app}"
|
||||
local action=${action:-start}
|
||||
local log_path="${log_path:-/var/log/$service_name/$service_name.log}"
|
||||
local length=${length:-20}
|
||||
local timeout=${timeout:-300}
|
||||
|
||||
ynh_print_info "Waiting for a response from $service_name..."
|
||||
ynh_print_info "Waiting for a response from $service_name..."
|
||||
|
||||
# Start to read the log
|
||||
if [[ -n "${line_match:-}" ]]
|
||||
then
|
||||
local templog="$(mktemp)"
|
||||
# Following the starting of the app in its log
|
||||
if [ "$log_path" == "systemd" ] ; then
|
||||
# Read the systemd journal
|
||||
journalctl -u $service_name -f -n0 > "$templog" &
|
||||
else
|
||||
# Read the specified log file
|
||||
tail -F -n0 "$log_path" > "$templog" &
|
||||
# Start to read the log
|
||||
if [[ -n "${line_match:-}" ]]; then
|
||||
local templog="$(mktemp)"
|
||||
# Following the starting of the app in its log
|
||||
if [ "$log_path" == "systemd" ]; then
|
||||
# Read the systemd journal
|
||||
journalctl -u $service_name -f -n0 >"$templog" &
|
||||
else
|
||||
# Read the specified log file
|
||||
tail -F -n0 "$log_path" >"$templog" &
|
||||
fi
|
||||
# Get the PID of the tail command
|
||||
local pid_tail=$!
|
||||
fi
|
||||
# Get the PID of the tail command
|
||||
local pid_tail=$!
|
||||
fi
|
||||
|
||||
echo "${action^} the service $service_name" >&2
|
||||
systemctl $action $service_name \
|
||||
|| ( journalctl --lines=$length -u $service_name >&2 \
|
||||
; test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 \
|
||||
; false )
|
||||
echo "${action^} the service $service_name" >&2
|
||||
systemctl $action $service_name ||
|
||||
(
|
||||
journalctl --lines=$length -u $service_name >&2 \
|
||||
;
|
||||
test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 \
|
||||
;
|
||||
false
|
||||
)
|
||||
|
||||
# Start the timeout and try to find line_match
|
||||
if [[ -n "${line_match:-}" ]]
|
||||
then
|
||||
local i=0
|
||||
for i in $(seq 1 $timeout)
|
||||
do
|
||||
# Read the log until the sentence is found, that means the app finished to start. Or run until the timeout
|
||||
if grep --quiet "$line_match" "$templog"
|
||||
then
|
||||
echo "The service $service_name has correctly started." >&2
|
||||
break
|
||||
fi
|
||||
echo -n "." >&2
|
||||
sleep 1
|
||||
done
|
||||
if [ $i -eq $timeout ]
|
||||
then
|
||||
echo "The service $service_name didn't fully started before the timeout." >&2
|
||||
journalctl --lines=$length -u $service_name >&2
|
||||
test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2
|
||||
fi
|
||||
# Start the timeout and try to find line_match
|
||||
if [[ -n "${line_match:-}" ]]; then
|
||||
local i=0
|
||||
for i in $(seq 1 $timeout); do
|
||||
# Read the log until the sentence is found, that means the app finished to start. Or run until the timeout
|
||||
if grep --quiet "$line_match" "$templog"; then
|
||||
echo "The service $service_name has correctly started." >&2
|
||||
break
|
||||
fi
|
||||
echo -n "." >&2
|
||||
sleep 1
|
||||
done
|
||||
if [ $i -eq $timeout ]; then
|
||||
echo "The service $service_name didn't fully started before the timeout." >&2
|
||||
journalctl --lines=$length -u $service_name >&2
|
||||
test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2
|
||||
fi
|
||||
|
||||
echo ""
|
||||
ynh_clean_check_starting
|
||||
fi
|
||||
echo ""
|
||||
ynh_clean_check_starting
|
||||
fi
|
||||
}
|
||||
|
||||
# Clean temporary process and file used by ynh_check_starting
|
||||
# (usually used in ynh_clean_setup scripts)
|
||||
#
|
||||
# usage: ynh_clean_check_starting
|
||||
ynh_clean_check_starting () {
|
||||
ynh_clean_check_starting() {
|
||||
# Stop the execution of tail.
|
||||
kill -s 15 $pid_tail 2>&1
|
||||
ynh_secure_remove "$templog" 2>&1
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,8 +42,8 @@ ynh_webpath_register $app $domain $path_url
|
|||
#=================================================
|
||||
|
||||
# Check user parameter
|
||||
ynh_user_exists "$admin" \
|
||||
|| ynh_die "The chosen admin user does not exist."
|
||||
ynh_user_exists "$admin" ||
|
||||
ynh_die "The chosen admin user does not exist."
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
|
@ -124,8 +124,8 @@ add_systemd_config
|
|||
|
||||
# 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 "/"
|
||||
# unprotected_uris allows SSO credentials to be passed anyway.
|
||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -37,8 +37,7 @@ ynh_remove_systemd_config
|
|||
#=================================================
|
||||
|
||||
# Remove a service from the admin panel, added by `yunohost service add`
|
||||
if yunohost service status | grep -q $app
|
||||
then
|
||||
if yunohost service status | grep -q $app; then
|
||||
echo "Remove $app service"
|
||||
yunohost service remove $app
|
||||
fi
|
||||
|
@ -66,18 +65,15 @@ ynh_secure_remove "/var/log/$app.log"
|
|||
# CLOSE PORTS
|
||||
#=================================================
|
||||
|
||||
if yunohost firewall list | grep -q "\- $port$"
|
||||
then
|
||||
if yunohost firewall list | grep -q "\- $port$"; then
|
||||
echo "Close port $port" >&2
|
||||
yunohost firewall disallow TCP $port 2>&1
|
||||
fi
|
||||
if yunohost firewall list | grep -q "\- $port_hub$"
|
||||
then
|
||||
if yunohost firewall list | grep -q "\- $port_hub$"; then
|
||||
echo "Close port $port_hub" >&2
|
||||
yunohost firewall disallow TCP $port_hub 2>&1
|
||||
fi
|
||||
if yunohost firewall list | grep -q "\- $port_http_proxy$"
|
||||
then
|
||||
if yunohost firewall list | grep -q "\- $port_http_proxy$"; then
|
||||
echo "Close port $port_http_proxy" >&2
|
||||
yunohost firewall disallow TCP $port_http_proxy 2>&1
|
||||
fi
|
||||
|
@ -92,4 +88,4 @@ ynh_remove_nginx_config
|
|||
# REMOVE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
#ynh_remove_logrotate
|
||||
#ynh_remove_logrotate
|
||||
|
|
|
@ -104,8 +104,8 @@ add_systemd_config
|
|||
|
||||
# If app is public, add url to SSOWat conf as skipped_uris
|
||||
if [[ $is_public -eq 1 ]]; then
|
||||
# See install script
|
||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
||||
# See install script
|
||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -124,4 +124,4 @@ yunohost service add $app --log "systemd"
|
|||
# START SERVICE
|
||||
#=================================================
|
||||
|
||||
ynh_systemd_action -n $app -a restart -l "JupyterHub is now running at" -p "systemd"
|
||||
ynh_systemd_action -n $app -a restart -l "JupyterHub is now running at" -p "systemd"
|
||||
|
|
Loading…
Reference in a new issue