mirror of
https://github.com/YunoHost-Apps/jupyterlab_ynh.git
synced 2024-09-03 19:26:35 +02:00
Merge pull request #4 from YunoHost-Apps/testing
Can enable or disable the terminal
This commit is contained in:
commit
0caee9f218
5 changed files with 66 additions and 39 deletions
|
@ -329,7 +329,7 @@ c.NotebookApp.terminado_settings = {'shell_command': ['/bin/bash']}
|
||||||
#
|
#
|
||||||
# Terminals may also be automatically disabled if the terminado package is not
|
# Terminals may also be automatically disabled if the terminado package is not
|
||||||
# available.
|
# available.
|
||||||
#c.NotebookApp.terminals_enabled = True
|
c.NotebookApp.terminals_enabled = bool(__ENABLE_TERMINAL__)
|
||||||
|
|
||||||
## Token used for authenticating first-time connections to the server.
|
## Token used for authenticating first-time connections to the server.
|
||||||
#
|
#
|
||||||
|
|
|
@ -59,6 +59,15 @@
|
||||||
"fr": "Est-ce une application publique ?"
|
"fr": "Est-ce une application publique ?"
|
||||||
},
|
},
|
||||||
"default": true
|
"default": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "enable_terminal",
|
||||||
|
"type": "boolean",
|
||||||
|
"ask": {
|
||||||
|
"en": "Enable terminal in the lab?",
|
||||||
|
"fr": "Activer le terminal dans le lab ?"
|
||||||
|
},
|
||||||
|
"default": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,25 +20,25 @@ elif [ -n "$(uname -m | grep arm)" ]; then
|
||||||
miniconda_architecture="arm"
|
miniconda_architecture="arm"
|
||||||
else
|
else
|
||||||
ynh_die "Unable to detect your achitecture, please open a bug describing \
|
ynh_die "Unable to detect your achitecture, please open a bug describing \
|
||||||
your hardware and the result of the command \"uname -m\"." 1
|
your hardware and the result of the command \"uname -m\"." 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE FOLDERS
|
# CREATE FOLDERS
|
||||||
#=================================================
|
#=================================================
|
||||||
create_dir() {
|
create_dir() {
|
||||||
mkdir -p "$config_path"
|
mkdir -p "$config_path"
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CONFIGURATION FILES FOR JUPYTERLAB
|
# CONFIGURATION FILES FOR JUPYTERLAB
|
||||||
#=================================================
|
#=================================================
|
||||||
config_jupyterlab() {
|
config_jupyterlab() {
|
||||||
create_dir
|
create_dir
|
||||||
|
|
||||||
jupyterlab_conf_path="$config_path/jupyterhub_config.py"
|
jupyterlab_conf_path="$config_path/jupyterhub_config.py"
|
||||||
|
|
||||||
ynh_backup_if_checksum_is_different $jupyterlab_conf_path
|
ynh_backup_if_checksum_is_different $jupyterlab_conf_path
|
||||||
|
|
||||||
# JupyterLab configuration
|
# JupyterLab configuration
|
||||||
cp -f ../conf/jupyterhub_config.py $jupyterlab_conf_path
|
cp -f ../conf/jupyterhub_config.py $jupyterlab_conf_path
|
||||||
|
@ -50,18 +50,20 @@ config_jupyterlab() {
|
||||||
ynh_replace_string "__FINAL_PATH__" "$final_path" $jupyterlab_conf_path
|
ynh_replace_string "__FINAL_PATH__" "$final_path" $jupyterlab_conf_path
|
||||||
ynh_replace_string "__ADMIN__" "$admin" $jupyterlab_conf_path
|
ynh_replace_string "__ADMIN__" "$admin" $jupyterlab_conf_path
|
||||||
|
|
||||||
ynh_store_file_checksum $jupyterlab_conf_path
|
ynh_store_file_checksum $jupyterlab_conf_path
|
||||||
}
|
}
|
||||||
|
|
||||||
config_jupyter_notebook() {
|
config_jupyter_notebook() {
|
||||||
jupyter_notebook_conf_path="$final_path/etc/jupyter/jupyter_notebook_config.py"
|
jupyter_notebook_conf_path="$final_path/etc/jupyter/jupyter_notebook_config.py"
|
||||||
|
|
||||||
ynh_backup_if_checksum_is_different $jupyter_notebook_conf_path
|
ynh_backup_if_checksum_is_different $jupyter_notebook_conf_path
|
||||||
|
|
||||||
# Jupyter notebook configuration
|
# Jupyter notebook configuration
|
||||||
cp -f ../conf/jupyter_notebook_config.py $jupyter_notebook_conf_path
|
cp -f ../conf/jupyter_notebook_config.py $jupyter_notebook_conf_path
|
||||||
|
|
||||||
ynh_store_file_checksum $jupyter_notebook_conf_path
|
ynh_replace_string "__ENABLE_TERMINAL__" "$enable_terminal" $jupyter_notebook_conf_path
|
||||||
|
|
||||||
|
ynh_store_file_checksum $jupyter_notebook_conf_path
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -108,41 +110,41 @@ update_src_version() {
|
||||||
#=================================================
|
#=================================================
|
||||||
# This function is inspired by the ynh_setup_source function, adapted to deal with .sh files
|
# This function is inspired by the ynh_setup_source function, adapted to deal with .sh files
|
||||||
setup_source() {
|
setup_source() {
|
||||||
local src_id=${1:-app} # If the argument is not given, source_id equals "app"
|
local src_id=${1:-app} # If the argument is not given, source_id equals "app"
|
||||||
|
|
||||||
update_src_version # Update source file
|
update_src_version # Update source file
|
||||||
|
|
||||||
# Load value from configuration file (see above for a small doc about this file
|
# Load value from configuration file (see above for a small doc about this file
|
||||||
# format)
|
# format)
|
||||||
local src_url=$(grep 'SOURCE_URL=' "$YNH_CWD/../conf/${src_id}.src" | cut -d= -f2-)
|
local src_url=$(grep 'SOURCE_URL=' "$YNH_CWD/../conf/${src_id}.src" | cut -d= -f2-)
|
||||||
local src_sum=$(grep 'SOURCE_SUM=' "$YNH_CWD/../conf/${src_id}.src" | cut -d= -f2-)
|
local src_sum=$(grep 'SOURCE_SUM=' "$YNH_CWD/../conf/${src_id}.src" | cut -d= -f2-)
|
||||||
local src_sumprg=$(grep 'SOURCE_SUM_PRG=' "$YNH_CWD/../conf/${src_id}.src" | cut -d= -f2-)
|
local src_sumprg=$(grep 'SOURCE_SUM_PRG=' "$YNH_CWD/../conf/${src_id}.src" | cut -d= -f2-)
|
||||||
local src_format=$(grep 'SOURCE_FORMAT=' "$YNH_CWD/../conf/${src_id}.src" | cut -d= -f2-)
|
local src_format=$(grep 'SOURCE_FORMAT=' "$YNH_CWD/../conf/${src_id}.src" | cut -d= -f2-)
|
||||||
local src_extract=$(grep 'SOURCE_EXTRACT=' "$YNH_CWD/../conf/${src_id}.src" | cut -d= -f2-)
|
local src_extract=$(grep 'SOURCE_EXTRACT=' "$YNH_CWD/../conf/${src_id}.src" | cut -d= -f2-)
|
||||||
local src_in_subdir=$(grep 'SOURCE_IN_SUBDIR=' "$YNH_CWD/../conf/${src_id}.src" | cut -d= -f2-)
|
local src_in_subdir=$(grep 'SOURCE_IN_SUBDIR=' "$YNH_CWD/../conf/${src_id}.src" | cut -d= -f2-)
|
||||||
local src_filename=$(grep 'SOURCE_FILENAME=' "$YNH_CWD/../conf/${src_id}.src" | cut -d= -f2-)
|
local src_filename=$(grep 'SOURCE_FILENAME=' "$YNH_CWD/../conf/${src_id}.src" | cut -d= -f2-)
|
||||||
|
|
||||||
# Default value
|
# Default value
|
||||||
src_sumprg=${src_sumprg:-sha256sum}
|
src_sumprg=${src_sumprg:-sha256sum}
|
||||||
src_in_subdir=${src_in_subdir:-true}
|
src_in_subdir=${src_in_subdir:-true}
|
||||||
src_format=${src_format:-tar.gz}
|
src_format=${src_format:-tar.gz}
|
||||||
src_format=$(echo "$src_format" | tr '[:upper:]' '[:lower:]')
|
src_format=$(echo "$src_format" | tr '[:upper:]' '[:lower:]')
|
||||||
src_extract=${src_extract:-true}
|
src_extract=${src_extract:-true}
|
||||||
if [ "$src_filename" = "" ] ; then
|
if [ "$src_filename" = "" ] ; then
|
||||||
src_filename="${src_id}.${src_format}"
|
src_filename="${src_id}.${src_format}"
|
||||||
fi
|
fi
|
||||||
local local_src="/opt/yunohost-apps-src/${YNH_APP_ID}/${src_filename}"
|
local local_src="/opt/yunohost-apps-src/${YNH_APP_ID}/${src_filename}"
|
||||||
|
|
||||||
if test -e "$local_src"
|
if test -e "$local_src"
|
||||||
then # Use the local source file if it is present
|
then # Use the local source file if it is present
|
||||||
cp $local_src $src_filename
|
cp $local_src $src_filename
|
||||||
else # If not, download the source
|
else # If not, download the source
|
||||||
local out=`wget -nv -O $src_filename $src_url 2>&1` || ynh_print_err $out
|
local out=`wget -nv -O $src_filename $src_url 2>&1` || ynh_print_err $out
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check the control sum
|
# Check the control sum
|
||||||
echo "${src_sum} ${src_filename}" | ${src_sumprg} -c --status \
|
echo "${src_sum} ${src_filename}" | ${src_sumprg} -c --status \
|
||||||
|| ynh_die "Corrupt source"
|
|| ynh_die "Corrupt source"
|
||||||
|
|
||||||
bash $src_filename -b -p $final_path
|
bash $src_filename -b -p $final_path
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,9 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
admin=$(ynh_app_setting_get "$app" admin)
|
||||||
port=$(ynh_app_setting_get "$app" port)
|
port=$(ynh_app_setting_get "$app" port)
|
||||||
|
port_hub=$(ynh_app_setting_get "$app" port_hub)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK PATHS SYNTAX
|
# CHECK PATHS SYNTAX
|
||||||
|
@ -63,6 +65,12 @@ fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
|
#=================================================
|
||||||
|
# STOP SERVICE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
yunohost service stop jupyterlab
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY URL IN NGINX
|
# MODIFY URL IN NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -95,4 +103,10 @@ config_jupyterlab
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
service nginx reload
|
service nginx reload
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# START SERVICE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
yunohost service start jupyterlab
|
|
@ -23,6 +23,7 @@ domain=$YNH_APP_ARG_DOMAIN
|
||||||
path_url=$YNH_APP_ARG_PATH
|
path_url=$YNH_APP_ARG_PATH
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
admin=$YNH_APP_ARG_ADMIN
|
admin=$YNH_APP_ARG_ADMIN
|
||||||
|
enable_terminal=$YNH_APP_ARG_ENABLE_TERMINAL
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REGISTER DOMAIN
|
# REGISTER DOMAIN
|
||||||
|
@ -51,6 +52,7 @@ ynh_app_setting_set $app admin $admin
|
||||||
ynh_app_setting_set $app domain $domain
|
ynh_app_setting_set $app domain $domain
|
||||||
ynh_app_setting_set $app path_url $path_url
|
ynh_app_setting_set $app path_url $path_url
|
||||||
ynh_app_setting_set $app is_public $is_public
|
ynh_app_setting_set $app is_public $is_public
|
||||||
|
ynh_app_setting_set $app enable_terminal $is_public
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
|
|
Loading…
Reference in a new issue