install 1.77 KB
Newer Older
Laurent Peuch's avatar
init  
Laurent Peuch committed
1
2
set -e

3
4
source ./commons

5
6
7
8
9
10
11
12
13
14
# Retrieve arguments
domain=$1
path=$2

# Check domain/path availability
sudo yunohost app checkurl $domain$path -a neutrinet
if [[ ! $? -eq 0 ]]; then
    exit 1
fi

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
install_static_file() {
    final_path=/var/www/neutrinet
    sudo mkdir -p $final_path
    sudo cp -a ../sources/ $final_path

    sudo chown -R www-data: $final_path

    if [[ "$path" == "" ]]; then
      sed -i "s@PATHTOCHANGE@/@g" ../conf/nginx.conf
    else
      sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
    fi

    sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf

    sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/neutrinet.conf
}
Laurent Peuch's avatar
Laurent Peuch committed
32

Laurent Peuch's avatar
init  
Laurent Peuch committed
33
34
35
install_renew_cert() {
    set -e

Laurent Peuch's avatar
Laurent Peuch committed
36
37
    install_dir=$(pwd)

38
    if [ -e $RENEW_CERT_PATH ]; then
Laurent Peuch's avatar
Laurent Peuch committed
39
        sudo rm -rf $RENEW_CERT_PATH
40
41
    fi

42
    sudo apt-get update
Laurent Peuch's avatar
init  
Laurent Peuch committed
43
44
    sudo apt-get install -y python-virtualenv

Laurent Peuch's avatar
Laurent Peuch committed
45
    sudo git clone https://github.com/neutrinet/renew_cert $RENEW_CERT_PATH
Laurent Peuch's avatar
init  
Laurent Peuch committed
46

Laurent Peuch's avatar
Laurent Peuch committed
47
    cd $RENEW_CERT_PATH
Laurent Peuch's avatar
init  
Laurent Peuch committed
48

Laurent Peuch's avatar
Laurent Peuch committed
49
    sudo git checkout ccc5b6b58010bb4166c2ae1a72df340395827f99 || echo ""
50

Laurent Peuch's avatar
init  
Laurent Peuch committed
51
52
53
54
55
56
57
58
    # 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
59
60
61
62
63
    set -e

    install_dir=$(pwd)

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

Laurent Peuch's avatar
Laurent Peuch committed
66
67
    cd $install_dir
}
Laurent Peuch's avatar
init  
Laurent Peuch committed
68

69
sudo yunohost app setting neutrinet version -v "0.1.1"
Laurent Peuch's avatar
init  
Laurent Peuch committed
70

71
sudo yunohost app fetchlist -n neutrinet -u https://neutrinet.be/apps.json
72
sudo yunohost app fetchlist -n labriqueinternet -u https://labriqueinter.net/apps/labriqueinternet.json
73

74
75
install_static_file

Laurent Peuch's avatar
init  
Laurent Peuch committed
76
77
78
install_renew_cert

# vpn is not running, let's assume for now that this mean that the vpn is broken
Laurent Peuch's avatar
Laurent Peuch committed
79
if [ ! "$(grep '^port 1195' /etc/openvpn/client.conf)" ]; then
Laurent Peuch's avatar
init  
Laurent Peuch committed
80
81
    renew_cert
fi