1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/yunorunner_ynh.git synced 2024-09-03 20:36:13 +02:00

Fix install and exec

This commit is contained in:
Maniack Crudelis 2018-08-26 21:45:44 +02:00
parent 12136751f3
commit 1fff8898a9
6 changed files with 108 additions and 20 deletions

View file

@ -6,6 +6,7 @@ After=network.target
Type=simple
User=__APP__
Group=__APP__
Environment="PYTHONHOME=__FINALPATH__/ve3/bin/" "PYTHONPATH=__FINALPATH__/.pythonz/pythons/CPython-3.6.6/lib/python3.6"
WorkingDirectory=__FINALPATH__
ExecStart=__FINALPATH__/ve3/bin/python ./run.py /home/CI_package_check/analyseCI.sh >> /var/log/__APP__/__APP__.log 2&>1

View file

@ -197,6 +197,108 @@ ynh_handle_getopts_args () {
#=================================================
ynh_print_log () {
echo "${1}"
}
# Print an info on stdout
#
# usage: ynh_print_info "Text to print"
# | arg: text - The text to print
ynh_print_info () {
ynh_print_log "[INFO] ${1}"
}
# Print a warning on stderr
#
# usage: ynh_print_warn "Text to print"
# | arg: text - The text to print
ynh_print_warn () {
ynh_print_log "[WARN] ${1}" >&2
}
# Print a error on stderr
#
# usage: ynh_print_err "Text to print"
# | arg: text - The text to print
ynh_print_err () {
ynh_print_log "[ERR] ${1}" >&2
}
# Execute a command and print the result as an error
#
# usage: ynh_exec_err command to execute
# usage: ynh_exec_err "command to execute | following command"
# In case of use of pipes, you have to use double quotes. Otherwise, this helper will be executed with the first command, then be send to the next pipe.
#
# | arg: command - command to execute
ynh_exec_err () {
ynh_print_err "$(eval $@)"
}
# Execute a command and print the result as a warning
#
# usage: ynh_exec_warn command to execute
# usage: ynh_exec_warn "command to execute | following command"
# In case of use of pipes, you have to use double quotes. Otherwise, this helper will be executed with the first command, then be send to the next pipe.
#
# | arg: command - command to execute
ynh_exec_warn () {
ynh_print_warn "$(eval $@)"
}
# Execute a command and force the result to be printed on stdout
#
# usage: ynh_exec_warn_less command to execute
# usage: ynh_exec_warn_less "command to execute | following command"
# In case of use of pipes, you have to use double quotes. Otherwise, this helper will be executed with the first command, then be send to the next pipe.
#
# | arg: command - command to execute
ynh_exec_warn_less () {
eval $@ 2>&1
}
# Execute a command and redirect stdout in /dev/null
#
# usage: ynh_exec_quiet command to execute
# usage: ynh_exec_quiet "command to execute | following command"
# In case of use of pipes, you have to use double quotes. Otherwise, this helper will be executed with the first command, then be send to the next pipe.
#
# | arg: command - command to execute
ynh_exec_quiet () {
eval $@ > /dev/null
}
# Execute a command and redirect stdout and stderr in /dev/null
#
# usage: ynh_exec_fully_quiet command to execute
# usage: ynh_exec_fully_quiet "command to execute | following command"
# In case of use of pipes, you have to use double quotes. Otherwise, this helper will be executed with the first command, then be send to the next pipe.
#
# | arg: command - command to execute
ynh_exec_fully_quiet () {
eval $@ > /dev/null 2>&1
}
# Remove any logs for all the following commands.
#
# usage: ynh_print_OFF
# WARNING: You should be careful with this helper, and never forgot to use ynh_print_ON as soon as possible to restore the logging.
ynh_print_OFF () {
set +x
}
# Restore the logging after ynh_print_OFF
#
# usage: ynh_print_ON
ynh_print_ON () {
set -x
# Print an echo only for the log, to be able to know that ynh_print_ON has been called.
echo ynh_print_ON > /dev/null
}
#=================================================
# Read the value of a key in a ynh manifest file
#
# usage: ynh_read_manifest manifest key

View file

@ -53,8 +53,3 @@ ynh_backup "/etc/logrotate.d/$app"
ynh_backup "/etc/systemd/system/$app.service"
#=================================================
# BACKUP OF PYTHONZ
#=================================================
ynh_backup "$HOME/.pythonz"

View file

@ -94,24 +94,24 @@ ynh_system_user_create $app # Créer un utilisateur système dédié à l'app
# Get pythonz
# curl -kL https://raw.githubusercontent.com/saghul/pythonz/master/pythonz-install
# ./pythonz-install
ynh_setup_source "$HOME/.pythonz" pythonz
ynh_setup_source "$final_path/.pythonz" pythonz
# Then install it
python $HOME/.pythonz/pythonz_install.py
python $final_path/.pythonz/pythonz_install.py
# if ! grep --quiet "YunoRunner" /root/.bashrc
# then
# [[ -s $HOME/.pythonz/etc/bashrc ]] && source $HOME/.pythonz/etc/bashrc # Added by YunoRunner
# [[ -s $final_path/.pythonz/etc/bashrc ]] && source $final_path/.pythonz/etc/bashrc # Added by YunoRunner
# fi
# Install Python 3.6.6
$HOME/.pythonz/bin/pythonz install 3.6.6
$final_path/.pythonz/bin/pythonz install 3.6.6
#=================================================
# INSTALL YUNORUNNER DEPENDENCIES
#=================================================
( cd $final_path
virtualenv -p $($HOME/.pythonz/bin/pythonz locate 3.6.6) ve3
virtualenv -p $($final_path/.pythonz/bin/pythonz locate 3.6.6) ve3
ve3/bin/pip3 install -r requirements.txt )
#=================================================

View file

@ -72,10 +72,6 @@ fi
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE PYTHONZ
#=================================================
ynh_secure_remove "$HOME/.pythonz"
# Suppression des log
ynh_secure_remove "/var/log/$app"

View file

@ -90,12 +90,6 @@ ynh_restore_file "/etc/systemd/system/$app.service"
## Démarrage auto du service
systemctl enable $app.service
#=================================================
# RESTORE OF PYTHONZ
#=================================================
ynh_restore_file "$HOME/.pythonz"
#=================================================
# BACKUP OF THE LOGROTATE CONFIGURATION
#=================================================