/** * Easy Installation Handler * Function to save special purpose * @param string $purpose */ public function _savePurpose($purpose = '') { if ($purpose == 'mpd') { // Install MPD Plugin $this->installPlugin('http://shop.max2play.com/media/downloadable/beta/mpd.tar', true, 2, false); // Disable Squeezebox-Server, Audioplayer, Remove Autostart Audioplayer $this->removePlugins(array('Audioplayer', 'Squeezebox Server')); $this->saveConfigFileParameter('/opt/max2play/autostart.conf', 'squeezelite', 0); $this->saveConfigFileParameter('/opt/max2play/autostart.conf', 'shairport', 0); $this->saveConfigFileParameter('/opt/max2play/autostart.conf', 'mpd', 1); $this->saveConfigFileParameter('/opt/max2play/autostart.conf', 'ympd', 1); //Create Sambashare for /var/lib/mpd include_once APPLICATION_PATH . '/model/Samba.php'; $smb = new Samba(); $test1 = $smb->setName('Max2Play-Music'); $test2 = $smb->setOption('path', '/var/lib/mpd'); $test3 = $smb->setOption('comment', 'Max2Play Music MPD'); $test4 = $smb->setOption('writeable', 'yes'); $test5 = $smb->setOption('create mode', '777'); shell_exec("echo '" . $smb->getShareConf() . "' >> /opt/max2play/samba.conf"); $output = shell_exec('sudo /opt/max2play/setSambaPass.sh "max2play"'); shell_exec("sudo /etc/init.d/samba restart"); $this->view->message[] = _t('You can access your Music-Folder from other computers via network. Password is "max2play".'); $this->view->message[] = _t('Music Player can be installed / started on Music Player (MPD) tab.'); } if ($purpose == 'squeeze') { $this->enablePlugin('Audioplayer', 2); $this->enablePlugin('Squeezebox Server', 4); $this->enablePlugin('Jivelite', 6); $this->loadViewHeader(true); $this->saveConfigFileParameter('/opt/max2play/autostart.conf', 'squeezelite', 1); $this->saveConfigFileParameter('/opt/max2play/autostart.conf', 'mpd', 0); $this->saveConfigFileParameter('/opt/max2play/autostart.conf', 'shairport', 0); $this->view->message[] = _t('Audioplayer Squeezelite is enabled and can be configured on Audioplayer-tab. Install a Squeezebox Server, if you do not already have one running.'); } if ($purpose == 'airplay') { $this->enablePlugin('Audioplayer', 2); $this->removePlugins(array('Squeezebox Server')); $this->saveConfigFileParameter('/opt/max2play/autostart.conf', 'squeezelite', 0); $this->saveConfigFileParameter('/opt/max2play/autostart.conf', 'shairport', 1); $this->saveConfigFileParameter('/opt/max2play/autostart.conf', 'mpd', 0); $this->view->message[] = _t('Airplay is now enabled by default.'); } $this->saveConfigFileParameter('/opt/max2play/options.conf', 'purpose', $purpose); }
/** * Add a new Sambashare * If this Method is called with $share as a already existing share it is not really adding a new one but deleting another -> see removeSambashare * use testparm to check config * @param Samba $share * @return boolean */ public function addSambashare($share = false) { if (!$share) { $smb = new Samba(); $test1 = $smb->setName($_GET['name']); $test2 = $smb->setOption('path', $_GET['path']); $test3 = $smb->setOption('comment', $_GET['comment']); $test4 = $smb->setOption('writeable', $_GET['writeable']); $test5 = $smb->setOption('create mode', $_GET['create_mode']); } else { $smb = $share; $test1 = true; } if ($test1) { shell_exec("echo '" . $smb->getShareConf() . "' >> " . $this->_sambaconf); $this->getSambaConfig(); if (!$share) { $this->view->message[] = _("Sambashare successfully added"); $this->restartSamba(); } return true; } $this->view->message[] = _("Sambashare NOT added! Please refer to the description below!"); return false; }