install 904 Bytes
Newer Older
Laurent Peuch's avatar
init  
Laurent Peuch committed
1
2
set -e

Laurent Peuch's avatar
Laurent Peuch committed
3
4
RENEW_CERT_PATH=/opt/neutrinet/renew_cert

Laurent Peuch's avatar
init  
Laurent Peuch committed
5
6
7
install_renew_cert() {
    set -e

Laurent Peuch's avatar
Laurent Peuch committed
8
9
    install_dir=$(pwd)

Laurent Peuch's avatar
init  
Laurent Peuch committed
10
11
    sudo apt-get install -y python-virtualenv

Laurent Peuch's avatar
Laurent Peuch committed
12
    sudo git clone https://github.com/neutrinet/renew_cert $RENEW_CERT_PATH
Laurent Peuch's avatar
init  
Laurent Peuch committed
13
14
15
16
17
18
19
20
21
22
23
24
25

    git checkout a6d09c2d77ce9bd4161d56e93fc5ce03187ad51c || echo ""

    cd /opt/renew_cert

    # I need system site packages otherwise moulinette is broken
    sudo virtualenv ve --system-site-packages
    sudo ve/bin/pip install -r requirements.txt

    cd $install_dir
}

renew_cert() {
Laurent Peuch's avatar
Laurent Peuch committed
26
27
28
29
30
    set -e

    install_dir=$(pwd)

    cd $RENEW_CERT_PATH
Laurent Peuch's avatar
init  
Laurent Peuch committed
31
32
    sudo ve/bin/python renew_from_cube.py

Laurent Peuch's avatar
Laurent Peuch committed
33
34
    cd $install_dir
}
Laurent Peuch's avatar
init  
Laurent Peuch committed
35
36
37
38
39
40
41
42
43

sudo yunohost app setting neutrinet version -v "0.1"

install_renew_cert

# vpn is not running, let's assume for now that this mean that the vpn is broken
if [ ! "$((ip -4 addr show tun0 | grep 'inet 80.67.181.') || echo '')" ]; then
    renew_cert
fi