|
@@ -19,16 +19,16 @@
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
*/
|
|
|
|
|
|
-function moulinette_hotspot_get($var) {
|
|
|
- return htmlspecialchars(exec('sudo yunohost app setting hotspot '.escapeshellarg($var)));
|
|
|
-}
|
|
|
+function ynh_setting_get($setting, $app = 'torclient') {
|
|
|
+ $value = exec("sudo grep \"^$setting:\" /etc/yunohost/apps/$app/settings.yml");
|
|
|
+ $value = preg_replace('/^[^:]+:\s*["\']?/', '', $value);
|
|
|
+ $value = preg_replace('/\s*["\']$/', '', $value);
|
|
|
|
|
|
-function moulinette_get($var) {
|
|
|
- return htmlspecialchars(exec('sudo yunohost app setting torclient '.escapeshellarg($var)));
|
|
|
+ return htmlspecialchars($value);
|
|
|
}
|
|
|
|
|
|
-function moulinette_set($var, $value) {
|
|
|
- return exec('sudo yunohost app setting torclient '.escapeshellarg($var).' -v '.escapeshellarg($value));
|
|
|
+function ynh_setting_set($setting, $value) {
|
|
|
+ return exec('sudo yunohost app setting torclient '.escapeshellarg($setting).' -v '.escapeshellarg($value));
|
|
|
}
|
|
|
|
|
|
function stop_service() {
|
|
@@ -54,8 +54,8 @@ function service_faststatus() {
|
|
|
}
|
|
|
|
|
|
dispatch('/', function() {
|
|
|
- $ssids = explode('|', moulinette_hotspot_get('wifi_ssid'));
|
|
|
- $wifi_device_id = moulinette_get('wifi_device_id');
|
|
|
+ $ssids = explode('|', ynh_setting_get('wifi_ssid', 'hotspot'));
|
|
|
+ $wifi_device_id = ynh_setting_get('wifi_device_id');
|
|
|
$wifi_ssid_list = '';
|
|
|
$wifi_ssid = '';
|
|
|
|
|
@@ -71,7 +71,7 @@ dispatch('/', function() {
|
|
|
}
|
|
|
|
|
|
set('faststatus', service_faststatus() == 0);
|
|
|
- set('service_enabled', moulinette_get('service_enabled'));
|
|
|
+ set('service_enabled', ynh_setting_get('service_enabled'));
|
|
|
set('wifi_device_id', $wifi_device_id);
|
|
|
set('wifi_ssid', $wifi_ssid);
|
|
|
set('wifi_ssid_list', $wifi_ssid_list);
|
|
@@ -96,10 +96,10 @@ dispatch_put('/settings', function() {
|
|
|
|
|
|
stop_service();
|
|
|
|
|
|
- moulinette_set('service_enabled', $service_enabled);
|
|
|
+ ynh_setting_set('service_enabled', $service_enabled);
|
|
|
|
|
|
if($service_enabled == 1) {
|
|
|
- moulinette_set('wifi_device_id', $_POST['wifi_device_id']);
|
|
|
+ ynh_setting_set('wifi_device_id', $_POST['wifi_device_id']);
|
|
|
|
|
|
$retcode = start_service();
|
|
|
|