Browse Source

Fix install php interface

Julien VAUBOURG 10 years ago
parent
commit
3783ab65b5
5 changed files with 36 additions and 14 deletions
  1. 2 2
      conf/nginx_vpnadmin.conf
  2. 3 3
      conf/phpfpm_vpnadmin.conf
  3. 1 1
      manifest.json
  4. 12 6
      scripts/install
  5. 18 2
      scripts/remove

+ 2 - 2
conf/nginx_vpnadmin.conf

@@ -1,5 +1,5 @@
 location <TPL:NGINX_LOCATION> {
-       alias <TPL:NGINX_ALIAS>;
+       alias <TPL:NGINX_REALPATH>;
        if ($scheme = http) {
            rewrite ^ https://$server_name$request_uri? permanent;
        }
@@ -8,7 +8,7 @@ location <TPL:NGINX_LOCATION> {
        try_files $uri $uri/ index.php;
        location ~ [^/]\.php(/|$) {
            fastcgi_split_path_info ^(.+?\.php)(/.*)$;
-           fastcgi_pass unix:/var/run/php5-fpm-roundcube.sock;
+           fastcgi_pass unix:/var/run/php5-fpm-<TPL:PHP_NAME>.sock;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param   REMOTE_USER   $remote_user;

+ 3 - 3
conf/phpfpm_vpnadmin.conf

@@ -24,7 +24,7 @@
 ;                            specific port;
 ;   '/path/to/unix/socket' - to listen on a unix socket.
 ; Note: This value is mandatory.
-listen = /var/run/php5-fpm-NAMETOCHANGE.sock
+listen = /var/run/php5-fpm-<TPL:PHP_NAME>.sock
 
 ; Set listen(2) backlog. A value of '-1' means unlimited.
 ; Default Value: 128 (-1 on FreeBSD and OpenBSD)
@@ -170,7 +170,7 @@ request_slowlog_timeout = 5s
 ; The log file for slow requests
 ; Default Value: not set
 ; Note: slowlog is mandatory if request_slowlog_timeout is set
-slowlog = /var/log/nginx/NAMETOCHANGE.slow.log
+slowlog = /var/log/nginx/<TPL:PHP_NAME>.slow.log
 
 ; Set open file descriptor rlimit.
 ; Default Value: system defined value
@@ -195,7 +195,7 @@ rlimit_core = 0
 ; Chdir to this directory at the start.
 ; Note: relative path can be used.
 ; Default Value: current directory or / when chroot
-chdir = /var/www/NAMETOCHANGE
+chdir = <TPL:NGINX_REALPATH>
 
 ; Redirect worker stdout and stderr into main error log. If not set, stdout and
 ; stderr will be redirected to /dev/null according to FastCGI specs.

+ 1 - 1
manifest.json

@@ -27,7 +27,7 @@
             "en": "Choose a path for your VPN web administration"
         },
         "example": "/vpnadmin",
-        "example": "/vpnadmin"
+        "default": "/vpnadmin"
       },
       {
         "name": "Server name",

+ 12 - 6
scripts/install

@@ -4,10 +4,10 @@
 domain=$1
 url_path=$2
 server_name=$3
-crt_client_path=$2
-crt_client_key_path=$3
-crt_server_ca_path=$4
-ip6_net=$5
+crt_client_path=$4
+crt_client_key_path=$5
+crt_server_ca_path=$6
+ip6_net=$7
 
 # Check arguments
 # TODO
@@ -32,6 +32,10 @@ ip6_addr=$(echo "$(echo ${ip6_expanded_net} | cut -d: -f1-7):1")
 ip6_addr=$(sipcalc ${ip6_addr} | grep Compressed | awk '{ print $NF; }')
 server_ip6=$(host ${server_name} | awk '/IPv6/ { print $NF; }')
 
+if [ -z "${server_ip6}" ]; then
+  server_ip6=$(host ${server_name} 80.67.188.188 | awk '/IPv6/ { print $NF; }')
+fi
+
 # Save arguments for future upgrades
 sudo yunohost app setting vpnclient wired_device -v ${wired_device}
 sudo yunohost app setting vpnclient ip6_addr -v ${ip6_addr}
@@ -47,7 +51,7 @@ sudo install -b -o root -g root -m 0644 ../conf/phpfpm_vpnadmin.conf /etc/php5/f
 # Copy web sources
 sudo mkdir -pm 0755 /var/www/vpnadmin/
 
-sudo cp -a ../conf/sources/* /var/www/vpnadmin/
+sudo cp -a ../sources/* /var/www/vpnadmin/
 
 sudo chown -R root: /var/www/vpnadmin/
 sudo chmod -R 0644 /var/www/vpnadmin/*
@@ -72,12 +76,14 @@ 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
+sudo sed 's|<TPL:NGINX_REALPATH>|/var/www/vpnadmin/|g' -i /etc/nginx/conf.d/${domain}.d/vpnadmin.conf
+sudo sed 's|<TPL:PHP_NAME>|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
+sudo sed 's|<TPL:NGINX_REALPATH>|/var/www/vpnadmin/|g' -i /etc/php5/fpm/pool.d/vpnadmin.conf
 
 # Copy init script
 sudo install -b -o root -g root -m 0755 ../conf/init_ynh-vpnclient /etc/init.d/ynh-vpnclient

+ 18 - 2
scripts/remove

@@ -1,16 +1,32 @@
 #!/bin/bash
 
+# Retrieve arguments
+domain=$(sudo yunohost app setting vpnclient domain)
+
 # The End
 sudo yunohost service stop ynh-vpnclient
 sudo yunohost service remove ynh-vpnclient
 sudo rm -f /etc/init.d/ynh-vpnclient
 
 # Remove confs
-sudo rm -f /etc/openvpn/client.conf* 
+sudo rm -f /etc/openvpn/client.conf{.tpl,}
+sudo rm -f /etc/nginx/conf.d/${domain}.d/vpnadmin.conf
+sudo rm -f /etc/php5/fpm/pool.d/vpnadmin.conf
 
 # Remove certificates
 sudo rm -rf /etc/openvpn/keys/
 
+# Restart services
+sudo yunohost service stop php5-fpm
+sudo yunohost service start php5-fpm
+sudo service nginx reload
+
+# Remove sources
+sudo rm -rf /var/www/vpnadmin/
+
+# Remove user
+sudo userdel -f vpnadmin
+
 # Restart hotspot service if installed to change NAT configuration
 sudo yunohost app list -f hotspot --json | grep -q '"installed": true'
 if [ "$?" -eq 0 ]; then
@@ -21,7 +37,7 @@ fi
 
 # Remove packets
 # The yunohost policy is currently to not uninstall packets (dependency problems)
-## sudo apt-get --assume-yes --force-yes remove openvpn
+## sudo apt-get --assume-yes --force-yes remove openvpn php5-fpm
 ## sudo apt-get --assume-yes --force-yes remove sipcalc
 
 exit 0