Browse Source

Ask for domain first and only complain if vpn files are not available

Bob Mottram 7 years ago
parent
commit
59c8de0089
1 changed files with 12 additions and 17 deletions
  1. 12
    17
      src/freedombone-mesh-connect

+ 12
- 17
src/freedombone-mesh-connect View File

157
     fi
157
     fi
158
 }
158
 }
159
 
159
 
160
-function connect_to_vpn {
161
-    dialog --title $"VPN Connect to another mesh network" \
162
-           --backtitle $"Freedombone Mesh" \
163
-           --defaultno \
164
-           --yesno $"\nHave you received the vpn.tar.gz file from the other mesh administrator, uncompressed it into the /home/fbone directory and also forwarded port $VPN_MESH_TLS_PORT from your internet router to this system?" 10 70
165
-    sel=$?
166
-    case $sel in
167
-        1) return;;
168
-        255) return;;
169
-    esac
170
-
160
+function connect_to_mesh {
171
     data=$(tempfile 2>/dev/null)
161
     data=$(tempfile 2>/dev/null)
172
     trap "rm -f $data" 0 1 2 5 15
162
     trap "rm -f $data" 0 1 2 5 15
173
-    dialog --title $"VPN Connect to another mesh network" \
163
+    dialog --title $"Connect to another mesh network" \
174
            --backtitle $"Freedombone Mesh" \
164
            --backtitle $"Freedombone Mesh" \
175
            --inputbox $'Enter the IP address or domain name of the other mesh.' 10 60 2>$data
165
            --inputbox $'Enter the IP address or domain name of the other mesh.' 10 60 2>$data
176
     sel=$?
166
     sel=$?
180
             if [ ${#ip_or_domain} -gt 1 ]; then
170
             if [ ${#ip_or_domain} -gt 1 ]; then
181
                 if [[ "$ip_or_domain" == *'.'* ]]; then
171
                 if [[ "$ip_or_domain" == *'.'* ]]; then
182
 
172
 
173
+                    connect_failed=
183
                     if [ ! -f ~/client.ovpn ]; then
174
                     if [ ! -f ~/client.ovpn ]; then
184
-                        rm $data
185
-                        exit 1
175
+                        connect_failed=1
186
                     fi
176
                     fi
187
                     if [ ! -f ~/stunnel.pem ]; then
177
                     if [ ! -f ~/stunnel.pem ]; then
188
-                        rm $data
189
-                        exit 1
178
+                        connect_failed=1
190
                     fi
179
                     fi
191
                     if [ ! -f ~/stunnel.p12 ]; then
180
                     if [ ! -f ~/stunnel.p12 ]; then
181
+                        connect_failed=1
182
+                    fi
183
+
184
+                    if [ $connect_failed ]; then
185
+                        dialog --title $"Connect to another mesh network" \
186
+                               --msgbox $"\nObtain the vpn.tar.gz file from the other mesh administrator, uncompress it into the /home/fbone directory and also forwarded port $VPN_MESH_TLS_PORT from your internet router to this system." 10 50
192
                         rm $data
187
                         rm $data
193
                         exit 1
188
                         exit 1
194
                     fi
189
                     fi
221
 esac
216
 esac
222
 case $(cat $data) in
217
 case $(cat $data) in
223
     1) rm $data
218
     1) rm $data
224
-       connect_to_vpn;;
219
+       connect_to_mesh;;
225
     2) rm $data
220
     2) rm $data
226
        mesh_setup_vpn;;
221
        mesh_setup_vpn;;
227
 esac
222
 esac