예제 #1
0
파일: daemon.php 프로젝트: dermidgen/moode
 		}
 		else {
 			$_SESSION['netconf']['wlan0']['ip'] = wrk_checkStrSysfile('/proc/net/wireless', 'wlan0')
 				? '--- NO IP ASSIGNED ---'
 				: '--- NO INTERFACE PRESENT ---';
 		}
 	}
 */
 sysCmd('service networking restart');
 // reset sourcecfg to defaults
 wrk_sourcecfg('reset');
 sendMpdCommand($mpd, 'update');
 // reset mpdconf to defaults
 $mpdconfdefault = ConfigDB::read('', 'mpdconfdefault');
 foreach ($mpdconfdefault as $element) {
     ConfigDB::update('cfg_mpd', $element['param'], $element['value_default']);
 }
 // tell worker to write new MPD config
 wrk_mpdconf();
 sysCmd('service mpd restart');
 // disable minidlna / samba / MPD startup
 sysCmd("update-rc.d -f minidlna remove");
 sysCmd("update-rc.d -f ntp remove");
 sysCmd("update-rc.d -f smbd remove");
 sysCmd("update-rc.d -f nmbd remove");
 sysCmd("update-rc.d -f mpd remove");
 sysCmd("echo 'manual' > /etc/init/minidlna.override");
 sysCmd("echo 'manual' > /etc/init/ntp.override");
 sysCmd("echo 'manual' > /etc/init/smbd.override");
 sysCmd("echo 'manual' > /etc/init/nmbd.override");
 sysCmd("echo 'manual' > /etc/init/mpd.override");
예제 #2
0
    // Tell worker to write new MPD config
    if ($workerSuccess = workerPushTask('mpdcfg')) {
        uiSetNotification('MPD config reset', 'Restarting MPD server...');
    }
}
// Handle restart (same as process for mpdcfg)
if (isset($_POST['mpdrestart']) && $_POST['mpdrestart'] == 1) {
    // Tell worker to write new MPD config
    if ($workerSuccess = workerPushTask('mpdcfg')) {
        uiSetNotification('MPD restart', 'MPD restarted');
    }
}
// Handle POST
if (isset($_POST['conf']) && !empty($_POST['conf'])) {
    foreach ($_POST['conf'] as $key => $value) {
        ConfigDB::update('cfg_mpd', $key, $value);
    }
    // Tell worker to write new MPD config
    if ($workerSuccess = workerPushTask('mpdcfg')) {
        uiSetNotification('MPD config modified', 'Restarting MPD server...');
    }
}
// Handle manual config
if (isset($_POST['mpdconf']) && !empty($_POST['mpdconf'])) {
    // tell worker to write new MPD config
    if ($workerSuccess = workerPushTask('mpdcfgman', $_POST['mpdconf'])) {
        uiSetNotification('MPD config modified', 'Restarting MPD server...');
    }
}
// could not start worker job
if (false === $workerSuccess) {
예제 #3
0
         $eth0 .= "address " . $_POST['eth0']['ip'] . "\n";
         $eth0 .= "netmask " . $_POST['eth0']['netmask'] . "\n";
         $eth0 .= "gateway " . $_POST['eth0']['gw'] . "\n";
         if (isset($_POST['eth0']['dns1']) && !empty($_POST['eth0']['dns1'])) {
             $eth0 .= "nameserver " . $_POST['eth0']['dns1'] . "\n";
         }
         if (isset($_POST['eth0']['dns2']) && !empty($_POST['eth0']['dns2'])) {
             $eth0 .= "nameserver " . $_POST['eth0']['dns2'] . "\n";
         }
     }
     $wlan0 = "\n";
 }
 // wlan0
 if (isset($_POST['wifisec']['ssid']) && !empty($_POST['wifisec']['ssid']) && $_POST['wifisec']['password'] && !empty($_POST['wifisec']['password'])) {
     $value = array('ssid' => $_POST['wifisec']['ssid'], 'encryption' => $_POST['wifisec']['encryption'], 'password' => $_POST['wifisec']['password']);
     ConfigDB::update('cfg_wifisec', '', $value);
     $wifisec = ConfigDB::read('cfg_wifisec');
     // format new config string for wlan0
     $wlan0 = "\n";
     $wlan0 .= "auto wlan0\n";
     $wlan0 .= "iface wlan0 inet dhcp\n";
     $wlan0 .= "wireless-power off\n";
     if ($_POST['wifisec']['encryption'] == 'wpa') {
         $wlan0 .= "wpa-ssid " . $_POST['wifisec']['ssid'] . "\n";
         // TC (Tim Curtis) 2015-08-DD: place holder, add quotes around ssid
         $wlan0 .= "wpa-psk " . $_POST['wifisec']['password'] . "\n";
     } else {
         $wlan0 .= "wireless-essid " . $_POST['wifisec']['ssid'] . "\n";
         // TC (Tim Curtis) 2015-08-DD: place holder, add quotes around ssid
         if ($_POST['wifisec']['encryption'] == 'wep') {
             $wlan0 .= "wireless-key " . bin2hex($_POST['wifisec']['password']) . "\n";
예제 #4
0
파일: worker.php 프로젝트: dermidgen/moode
function wrk_sourcecfg($queueargs)
{
    $action = $queueargs['mount']['action'];
    unset($queueargs['mount']['action']);
    switch ($action) {
        case 'reset':
            $source = ConfigDB::read('cfg_source');
            foreach ($source as $mp) {
                sysCmd("umount -f '/mnt/NAS/" . $mp['name'] . "'");
                sysCmd("rmdir '/mnt/NAS/" . $mp['name'] . "'");
            }
            $return = ConfigDB::delete('cfg_source') ? 1 : 0;
            break;
        case 'add':
            print_r($queueargs);
            unset($queueargs['mount']['id']);
            // write new entry
            $newmountID = ConfigDB::write('cfg_source', array_values($queueargs['mount']));
            $return = wrk_sourcemount('mount', $newmountID) ? 1 : 0;
            break;
        case 'edit':
            $mp = ConfigDB::read('cfg_source', '', $queueargs['mount']['id']);
            ConfigDB::update('cfg_source', '', $queueargs['mount']);
            sysCmd("umount -f '/mnt/NAS/" . $mp[0]['name'] . "'");
            if ($mp[0]['name'] != $queueargs['mount']['name']) {
                sysCmd("rmdir '/mnt/NAS/" . $mp[0]['name'] . "'");
                sysCmd("mkdir '/mnt/NAS/" . $queueargs['mount']['name'] . "'");
            }
            $return = wrk_sourcemount('mount', $queueargs['mount']['id']) ? 1 : 0;
            break;
        case 'delete':
            $mp = ConfigDB::read('cfg_source', '', $queueargs['mount']['id']);
            sysCmd("umount -f '/mnt/NAS/" . $mp[0]['name'] . "'");
            sysCmd("rmdir '/mnt/NAS/" . $mp[0]['name'] . "'");
            $return = ConfigDB::delete('cfg_source', $queueargs['mount']['id']) ? 1 : 0;
            break;
    }
    return $return;
}
예제 #5
0
파일: Session.php 프로젝트: dermidgen/moode
 /**
  * Update session and config table
  */
 public static function update($key, $val)
 {
     $_SESSION[$key] = $val;
     ConfigDB::update('cfg_engine', $key, $val);
 }