Browse Source

[fix] Upgrade to 2.0

ljf 3 years ago
parent
commit
4235ca10a8
4 changed files with 20 additions and 7 deletions
  1. 2 2
      conf/ynh-vpnclient
  2. 0 1
      config_panel.toml
  3. 2 1
      scripts/install
  4. 16 3
      scripts/upgrade

+ 2 - 2
conf/ynh-vpnclient

@@ -143,8 +143,8 @@ is_dns_set() {
   if [[ "$ynh_dns_method" == "custom" ]]
   then
   
-    current_dns=$(grep -o -P '\s*nameserver\s+\K[ABCDEFabcdef\d.:]+' /etc/resolv.dnsmasq.conf | sort | uniq)
-    wanted_dns=$(echo "${ynh_dns}" | sort | uniq)
+    current_dns=$(grep -o -P '\s*nameserver\s+\K[abcdefabcdef\d.:]+' /etc/resolv.dnsmasq.conf | sort | uniq)
+    wanted_dns=$(echo "${ynh_dns}" | sed 's/,/\n/g'  | sort | uniq)
     [ -e /etc/dhcp/dhclient-exit-hooks.d/ynh-vpnclient ]\
     && [[ "$current_dns" == "$wanted_dns" ]]
   else

+ 0 - 1
config_panel.toml

@@ -83,7 +83,6 @@ name = "DNS & IPv6"
         [advanced.dns.dns_method]
         ask = "DNS provider"
         type = "select"
-        choices.pushed = "Use DNS from my VPN provider"
         choices.yunohost = "Keep DNS from YunoHost"
         choices.custom = "Use custom DNS"
 

+ 2 - 1
scripts/install

@@ -59,9 +59,10 @@ ynh_app_setting_set "$app" final_path "$final_path"
 
 # Default values for config panel
 ynh_app_setting_set "$app" service_enabled 0
-ynh_app_setting_set "$app" dns_method "pushed"
+ynh_app_setting_set "$app" dns_method "yunohost"
 ynh_app_setting_set "$app" nameservers ""
 ynh_app_setting_set "$app" ip6_addr ""
+ynh_app_setting_set "$app" ip6_net ""
 
 #=================================================
 # STANDARD MODIFICATIONS

+ 16 - 3
scripts/upgrade

@@ -17,9 +17,9 @@ ynh_print_info "Loading installation settings..."
 app=$YNH_APP_INSTANCE_NAME
 
 domain=$(ynh_app_setting_get $app domain)
-path_url=$(ynh_app_setting_get $app path)
-is_public=$(ynh_app_setting_get $app is_public)
 final_path=$(ynh_app_setting_get $app final_path)
+dns_method=$(ynh_app_setting_get $app dns_method)
+nameservers=$(ynh_app_setting_get $app nameservers)
 
 #=================================================
 # SPECIAL UPGRADE FOR VERSIONS < 1.2.0
@@ -30,9 +30,22 @@ rm -f /etc/nginx/conf.d/${domain}.d/vpnadmin.conf 2>/dev/null
 rm -f /etc/php/*/fpm/pool.d/vpnadmin.conf 2>/dev/null 
 
 if [ -d /var/www/vpnadmin ]; then
-  mv /var/www/vpnadmin /var/www/${app}
+  ynh_secure_remove /var/www/vpnadmin
+fi
+if [ -d /var/www/${app} ]; then
+  ynh_secure_remove /var/www/${app}
 fi
 
+#=================================================
+# SPECIAL UPGRADE FOR VERSIONS < 2.0
+#=================================================
+if [ -z "$dns_method" ]; then
+    ynh_app_setting_set --app=$app --key=dns_method --value=custom
+fi
+if [ -z "$nameservers" ]; then
+    nameservers="$(grep -o -P '\s*nameserver\s+\K[abcdefabcdef\d.:]+' /etc/resolv.dnsmasq.conf | sort | uniq | paste -s -d, -)"
+    ynh_app_setting_set --app=$app --key=nameservers --value="$nameservers"
+fi
 ## Versions known to have a buggy backup script
 #buggy_versions="1.0.0 1.0.1 1.1.0"
 #curr_version=$(read_manifest version)