Browse Source

Multissid beta without web interface

Julien VAUBOURG 10 years ago
parent
commit
8dc2896762
2 changed files with 26 additions and 2 deletions
  1. 23 2
      conf/init_ynh-piratebox
  2. 3 0
      scripts/install

+ 23 - 2
conf/init_ynh-piratebox

@@ -113,6 +113,19 @@ stop_fakedns() {
 
 ## Tools
 
+moulinette_get() {
+  var=${1}
+
+  value=$(yunohost app setting piratebox "${var}")
+
+  if [[ "${value}" =~ "An instance is already running" ]]; then
+    echo "${value}" >&2
+    exit 1
+  fi
+
+  echo "${value}"
+}
+
 moulinette_hotspot_get() {
   var=${1}
 
@@ -138,8 +151,16 @@ if [ "$1" != restart ]; then
   
   echo -n "Retrieving Yunohost settings... "
   
-  ynh_wifi_device=$(moulinette_hotspot_get wifi_device)
-  ynh_ip4_nat_prefix=$(moulinette_hotspot_get ip4_nat_prefix)
+  ynh_wifi_device_id=$(moulinette_get wifi_device_id)
+
+  if [ "${ynh_wifi_device_id}" -eq 0 ]; then
+    ynh_wifi_device="$(moulinette_hotspot_get wifi_device)"
+  else
+    ynh_wifi_device="hotspot${ynh_wifi_device_id}"
+  fi
+
+  IFS='|' read -a ynh_ip4_nat_prefix <<< "$(moulinette_hotspot_get ip4_nat_prefix)"
+  ynh_ip4_nat_prefix=${ynh_ip4_nat_prefix[${ynh_wifi_device_id}]}
   
   echo "OK"
 fi

+ 3 - 0
scripts/install

@@ -48,6 +48,9 @@ if [ ! $? -eq 0 ]; then
   exit 1
 fi
 
+# Save arguments
+sudo yunohost app setting piratebox wifi_device_id -v 0
+
 # Install packages
 packages='php5-fpm iptables libnet-dns-perl git'
 export DEBIAN_FRONTEND=noninteractive