Install php interface vpnadmin

This commit is contained in:
Julien VAUBOURG
2014-11-08 16:53:47 +01:00
parent 4b244633da
commit 8c49af4731
6 changed files with 320 additions and 5 deletions

View File

@@ -1,7 +1,9 @@
#!/bin/bash
# Retrieve arguments
server_name=$1
domain=$1
url_path=$2
server_name=$3
crt_client_path=$2
crt_client_key_path=$3
crt_server_ca_path=$4
@@ -10,8 +12,14 @@ ip6_net=$5
# Check arguments
# TODO
# Check domain/path availability
sudo yunohost app checkurl ${domain}${url_path} -a vpnclient
if [[ ! $? -eq 0 ]]; then
exit 1
fi
# Install packages
sudo apt-get --assume-yes --force-yes install openvpn
sudo apt-get --assume-yes --force-yes install openvpn php5-fpm
# Install extra packages
sudo apt-get --assume-yes --force-yes install sipcalc
@@ -32,7 +40,18 @@ sudo yunohost app setting vpnclient server_name -v ${server_name}
sudo yunohost app setting vpnclient server_ip6 -v ${server_ip6}
# Copy confs
sudo install -b -o root -g root -m 0644 ../conf/client.conf.tpl /etc/openvpn/
sudo install -b -o root -g root -m 0644 ../conf/openvpn_client.conf.tpl /etc/openvpn/client.conf.tpl
sudo install -b -o root -g root -m 0644 ../conf/nginx_vpnadmin.conf /etc/nginx/conf.d/${domain}.d/vpnadmin.conf
sudo install -b -o root -g root -m 0644 ../conf/phpfpm_vpnadmin.conf /etc/php5/fpm/pool.d/vpnadmin.conf
# Copy web sources
sudo mkdir -pm 0755 /var/www/vpnadmin/
sudo cp -a ../conf/sources/* /var/www/vpnadmin/
sudo chown -R root: /var/www/vpnadmin/
sudo chmod -R 0644 /var/www/vpnadmin/*
sudo find /var/www/vpnadmin/ -type d -exec chmod +x {} \;
# Copy certificates
sudo mkdir -pm 0700 /etc/openvpn/keys/
@@ -44,12 +63,24 @@ sudo install -b -o root -g root -m 0600 ${crt_server_ca_path} /etc/openvpn/keys/
sudo rm -f ${crt_client_path} ${crt_client_key_path} ${crt_server_ca_path}
# Create user for the web admin
sudo useradd -MUr vpnadmin
# Fix confs
## openvpn
sudo sed "s|<TPL:SERVER_NAME>|${server_name}|g" -i /etc/openvpn/client.conf.tpl
## nginx
sudo sed "s|<TPL:NGINX_LOCATION>|${url_path}|g" -i /etc/nginx/conf.d/${domain}.d/vpnadmin.conf
sudo sed 's|<TPL:NGINX_ALIAS>|/var/www/vpnadmin/|g' -i /etc/nginx/conf.d/${domain}.d/vpnadmin.conf
# php-fpm
sudo sed 's|<TPL:PHP_NAME>|vpnadmin|g' -i /etc/php5/fpm/pool.d/vpnadmin.conf
sudo sed 's|<TPL:PHP_USER>|vpnadmin|g' -i /etc/php5/fpm/pool.d/vpnadmin.conf
sudo sed 's|<TPL:PHP_GROUP>|vpnadmin|g' -i /etc/php5/fpm/pool.d/vpnadmin.conf
# Copy init script
sudo install -b -o root -g root -m 0755 ../conf/ynh-vpnclient /etc/init.d/
sudo install -b -o root -g root -m 0755 ../conf/init_ynh-vpnclient /etc/init.d/ynh-vpnclient
# Fix init script
## ynh-vpnclient
@@ -65,11 +96,20 @@ sudo yunohost service add openvpn
sudo yunohost service stop openvpn
sudo yunohost service disable openvpn
# Gooo
sudo yunohost service add php5-fpm
sudo yunohost service enable php5-fpm
sudo yunohost service stop php5-fpm
sudo yunohost service start php5-fpm
sudo yunohost service add ynh-vpnclient
sudo yunohost service enable ynh-vpnclient
sudo yunohost service start ynh-vpnclient
sudo service nginx reload
# Update SSO for vpnadmin
sudo yunohost app ssowatconf
# Restart hotspot service if installed to change NAT configuration (now on tun0)
sudo yunohost app list -f hotspot --json | grep -q '"installed": true'
if [ "$?" -eq 0 ]; then