install 1.78 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
install_static_file() {
Laurent Peuch's avatar
Laurent Peuch committed
16 17
    set -e

18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
    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
34

Laurent Peuch's avatar
init  
Laurent Peuch committed
35 36 37
install_renew_cert() {
    set -e

Laurent Peuch's avatar
Laurent Peuch committed
38 39
    install_dir=$(pwd)

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

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

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

Laurent Peuch's avatar
Laurent Peuch committed
49
    cd $RENEW_CERT_PATH
Laurent Peuch's avatar
init  
Laurent Peuch committed
50

Laurent Peuch's avatar
Laurent Peuch committed
51
    sudo git checkout ccc5b6b58010bb4166c2ae1a72df340395827f99 || echo ""
52

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

    install_dir=$(pwd)

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

Laurent Peuch's avatar
Laurent Peuch committed
68 69
    cd $install_dir
}
Laurent Peuch's avatar
init  
Laurent Peuch committed
70

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

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

76 77
install_static_file

Laurent Peuch's avatar
init  
Laurent Peuch committed
78 79 80
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
81
if [ ! "$(grep '^port 1195' /etc/openvpn/client.conf)" ]; then
Laurent Peuch's avatar
init  
Laurent Peuch committed
82 83
    renew_cert
fi