Commit 68e0ade7 authored by HgO's avatar HgO
Browse files

Merge branch '12-virtualenv' into 'develop'

Fix missing pip when creating virtualenv on some systems

See merge request Neutrinet/neutrinet_ynh!16
parents 0b0a2618 7591009b
......@@ -2,10 +2,10 @@
"name": "Neutrinet",
"id": "neutrinet",
"description": {
"en": "Auto renewall for the Neutrinet vpn-certificates",
"en": "Auto renewal for the Neutrinet vpn-certificates",
"fr": "Renouvellement automatique des certificats vpn Neutrinet"
},
"version": "0.3.0~ynh1",
"version": "0.3.0~ynh4",
"license": "GPL-3+",
"maintainer": {
"name": "ilja",
......
......@@ -70,7 +70,7 @@ ynh_app_setting_set $app opt_path $opt_path
ynh_print_info "Installing dependencies…"
ynh_install_app_dependencies git python3-venv libssl-dev libffi-dev python3-dev
ynh_install_app_dependencies git python3-openssl python3-requests
#=================================================
# CREATE DEDICATED USER
......@@ -105,8 +105,6 @@ service nginx reload
renew_cert_repo="https://github.com/neutrinet/renew_cert"
renew_cert_version=$(jq .version ../manifest.json -r -e | cut -d '~' -f 1)
renew_cert_path="$opt_path/renew_cert"
renew_cert_virtualenv="$renew_cert_path/ve"
renew_cert_python="$renew_cert_virtualenv/bin/python3"
renew_cert_cron_script="renew_cert_cron.sh"
ynh_print_info "Installing automatic VPN certificate renewal…"
......@@ -118,19 +116,11 @@ git -C $renew_cert_path checkout $renew_cert_version
# This wrapper will be used as a daily cron task
cp $renew_cert_cron_script $renew_cert_path/$renew_cert_cron_script
# From now on we work in the renew_cert directory
cd $renew_cert_path
# We need system site packages otherwise moulinette is broken
python3 -m venv $renew_cert_virtualenv --system-site-packages
ve/bin/pip install wheel
ve/bin/pip install -r requirements.txt
ynh_print_info "Setting up permissions"
chown -R $app_user: $opt_path
chmod 0755 $renew_cert_cron_script
chown root: $renew_cert_cron_script
chmod 0755 $renew_cert_path/$renew_cert_cron_script
chown root: $renew_cert_path/$renew_cert_cron_script
#=================================================
# SETTING UP CRONTAB
......@@ -141,7 +131,7 @@ ynh_print_info "Setting up cron job for certificate renewal…"
cat <<EOF > /etc/cron.daily/$app-renew-cert
#!/bin/bash
cd $renew_cert_path
RENEW_CERT_PYTHON="$renew_cert_python" $renew_cert_path/$renew_cert_cron_script
$renew_cert_path/$renew_cert_cron_script
EOF
chown root:root /etc/cron.daily/$app-renew-cert
......
......@@ -50,7 +50,7 @@ fi
ynh_print_info "Installing dependencies…"
ynh_install_app_dependencies git python3-venv libssl-dev libffi-dev python3-dev
ynh_install_app_dependencies git python3-openssl python3-requests
#=================================================
# CREATE DEDICATED USER
......
......@@ -87,11 +87,14 @@ ynh_abort_if_errors
if [[ $version < "0.3.0~ynh1" ]]; then
ynh_app_setting_delete $app version
ynh_system_user_create --username $app_user --home_dir $www_path
fi
ynh_print_info "Upgrading dependencies..."
if [[ $version < "0.3.0~ynh4" ]]; then
ynh_print_info "Removing old dependencies..."
ynh_remove_app_dependencies virtualenv python3-venv libssl-dev libffi-dev python3-dev
ynh_package_update
ynh_install_app_dependencies python3-venv libssl-dev libffi-dev python3-dev
ynh_print_info "Upgrading dependencies..."
ynh_install_app_dependencies python3-openssl python3-requests
fi
#=================================================
......@@ -122,12 +125,12 @@ ynh_print_info "Installing automatic VPN certificate renewal..."
renew_cert_repo="https://github.com/neutrinet/renew_cert"
renew_cert_version=$(jq .version ../manifest.json -r -e | cut -d '~' -f 1)
renew_cert_path="$opt_path/renew_cert"
renew_cert_virtualenv="$renew_cert_path/ve"
renew_cert_python="$renew_cert_virtualenv/bin/python3"
renew_cert_cron_script="renew_cert_cron.sh"
if [[ ! -e $renew_cert_path ]]; then
git clone $renew_cert_repo $renew_cert_path
else
git -C $renew_cert_path fetch -t
fi
git -C $renew_cert_path checkout $renew_cert_version
......@@ -136,21 +139,11 @@ git -C $renew_cert_path checkout $renew_cert_version
# This wrapper will be used as a daily cron task
cp $renew_cert_cron_script $renew_cert_path/$renew_cert_cron_script
# From now on we work in the renew_cert directory
cd $renew_cert_path
if [[ ! -e $renew_cert_virtualenv || $version < "0.3.0~ynh1" ]]; then
# We need system site packages otherwise moulinette is broken
python3 -m venv $renew_cert_virtualenv --system-site-packages
fi
ve/bin/pip install wheel
ve/bin/pip install -r requirements.txt
ynh_print_info "Setting up permissions"
chown -R $app_user: $opt_path
chmod 755 $renew_cert_cron_script
chown root: $renew_cert_cron_script
chmod 755 $renew_cert_path/$renew_cert_cron_script
chown root: $renew_cert_path/$renew_cert_cron_script
#=================================================
# SETTING UP CRONTAB
......@@ -161,7 +154,7 @@ ynh_print_info "Setting up cron job for renewal..."
cat <<EOF > /etc/cron.daily/$app-renew-cert
#!/bin/bash
cd $renew_cert_path
RENEW_CERT_PYTHON="$renew_cert_python" $renew_cert_path/$renew_cert_cron_script
$renew_cert_path/$renew_cert_cron_script
EOF
chown root:root /etc/cron.daily/$app-renew-cert
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment