Skip to content

Commit 7a6f8a4

Browse files
committed
Added a 'token' file to find int he root directory using a 40 characted random string as the name and the code in the Configuration Appto find it. This will allow the working direcotry of RaspiWiFi to be found no matter where it is on the system. The app seems to run in the root directory context no matter what, probably because it runs from rc.local
1 parent 6c83b0c commit 7a6f8a4

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

Configuration App/app/models/main.rb

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,29 @@ def self.create_wpa_supplicant(user_ssid, encryption_type, user_wifi_key)
103103
end
104104

105105
def self.set_ap_client_mode
106-
system ('sudo cp -r /home/pi/Projects/RaspiWiFi/Reset\ Device/static_files/interfaces.apclient /etc/network/interfaces')
107-
system ('sudo cp -r /home/pi/Projects/RaspiWiFi/Reset\ Device/static_files/rc.local.apclient /etc/rc.local')
108-
system ('sudo cp -r /home/pi/Projects/RaspiWiFi/Reset\ Device/static_files/isc-dhcp-server.apclient /etc/default/isc-dhcp-server')
106+
raspiwifi_path = find_raspiwifi_path()
107+
108+
system ('sudo cp -r ' + raspiwifi_path + '/Reset\ Device/static_files/interfaces.apclient /etc/network/interfaces')
109+
system ('sudo cp -r ' + raspiwifi_path + '/Reset\ Device/static_files/rc.local.apclient /etc/rc.local')
110+
system ('sudo cp -r ' + raspiwifi_path + '/Reset\ Device/static_files/isc-dhcp-server.apclient /etc/default/isc-dhcp-server')
109111
system ('sudo reboot')
110112
end
111113

112114
def self.reset_all
115+
raspiwifi_path = find_raspiwifi_path()
116+
113117
system ('sudo rm -f /etc/wpa_supplicant/wpa_supplicant.conf')
114-
system ('rm -f ../tmp/*')
115-
system ('sudo cp -r /home/pi/Projects/RaspiWiFi/Reset\ Device/static_files/interfaces.aphost /etc/network/interfaces')
116-
system ('sudo cp -r /home/pi/Projects/RaspiWiFi/Reset\ Device/static_files/rc.local.aphost /etc/rc.local')
118+
system ('rm -f ' + raspiwifi_path + '/tmp/*')
119+
system ('sudo cp -r ' + raspiwifi_path + '/Reset\ Device/static_files/interfaces.aphost /etc/network/interfaces')
120+
system ('sudo cp -r ' + raspiwifi_path + '/Reset\ Device/static_files/rc.local.aphost /etc/rc.local')
117121
system ('sudo reboot')
118122
end
123+
124+
def self.find_raspiwifi_path
125+
find_path = %x(sudo find / -name "GSbSFZwWV1mig4vFSmbLW9iP8TfGfMYCPfHTqGcD")
126+
raspiwifi_path = find_path[0..-43]
127+
128+
raspiwifi_path
129+
end
119130

120131
end

GSbSFZwWV1mig4vFSmbLW9iP8TfGfMYCPfHTqGcD

Whitespace-only changes.

0 commit comments

Comments
 (0)