diff options
| -rw-r--r-- | application/controllers/ResourceController.php | 49 | ||||
| -rw-r--r-- | application/views/scripts/resource/getconfig.phtml | 32 |
2 files changed, 60 insertions, 21 deletions
diff --git a/application/controllers/ResourceController.php b/application/controllers/ResourceController.php index c078fb2..6ae3aed 100644 --- a/application/controllers/ResourceController.php +++ b/application/controllers/ResourceController.php @@ -272,7 +272,7 @@ class ResourceController extends Zend_Controller_Action $prebootpath = "../resources/bootmedium/".$prebootID."/"; mkdir($prebootpath ,0777, true); - if($_FILES['preboot']['name'] != ''){ + if($_FILES['preboot']['name'] != '' ){ move_uploaded_file($_FILES['preboot']['tmp_name'], $prebootpath."preboot.zip"); } @@ -369,6 +369,8 @@ class ResourceController extends Zend_Controller_Action public function getconfigAction() { + $this->initView(); + $bootmenuentryID = $this->thisSession->getBootmenuentryID(); $bootmenuentry = new Application_Model_BootMenuEntries(); $bmm = new Application_Model_BootMenuEntriesMapper(); @@ -417,47 +419,52 @@ class ResourceController extends Zend_Controller_Action foreach($bootosuser as $user) $test[] = $user->getLogin(); } + + $f = fopen("$tmp_conf/initramfs/postinit.local", "a"); + foreach($bootosuser as $user){ if($user->getLogin() == '%username%'){ - $loginname = $username; - }else{ - $loginname = $user->getLogin(); + $this->view->loginname = $username; + }else{ + $this->view->loginname = $user->getLogin(); } if($user->getPassword() == '%password%'){ - $password = $userpassword; + $this->view->password = $userpassword; }else{ - $password = $user->getPassword(); + $this->view->password = $user->getPassword(); } if($user->getHometypeID() == 2){ - $homepath = $user->getHomepath(); + $this->view->homepath = $user->getHomepath(); }elseif($user->getHometypeID() == 1){ - $homepath = "/media/openslx-stick/home/$loginname"; + $this->view->homepath = "/media/openslx-stick/home/".$this->view->loginname; }else{ - $homepath = "/home/$loginname"; + $this->view->homepath = "/home/".$this->view->loginname; } - - if($loginname != '' && $password != ''){ + + if($this->view->loginname != '' && $this->view->password != ''){ + if($user->getHometypeID() == 1){ - exec("echo 'modprobe usb_storage' >> $tmp_conf/initramfs/postinit.local"); - exec("echo 'echo -n 'Mounting OpenSLX-Stick:'; while [ ! -e /dev/sdb1 ] \n do \n\t usleep 500000 \n\t mdev -s \n\t echo -n . \n done' >> $tmp_conf/initramfs/postinit.local"); - exec("echo 'mkdir -p /mnt/media/openslx-stick' >> $tmp_conf/initramfs/postinit.local"); - exec("echo 'mount /dev/sdb1 /mnt/media/openslx-stick' >> $tmp_conf/initramfs/postinit.local"); - exec("echo 'if [ -d /mnt/media/openslx-stick/boot ]; then \n\t if [ ! -d '".escapeshellarg("'"."/mnt/media/openslx-stick/home/".$loginname."'")."' ]; then \n\t\t mkdir -p '".escapeshellarg("'"."/mnt/media/openslx-stick/home/'")."' \n\t\t chroot /mnt useradd -m -d '".escapeshellarg("'".$homepath."'")."' -s /bin/bash -p '".escapeshellarg("'".$password."'")."' '".escapeshellarg("'".$loginname."'")."' \n\t else \n\t\t chroot /mnt useradd -d '".escapeshellarg("'".$homepath."'")."' -s '/bin/bash' -p '".escapeshellarg("'".$password."'")."' '".escapeshellarg("'".$loginname."'")."' \n\t fi \n else \n\t chroot /mnt useradd -d '".escapeshellarg("'"."/home/".$loginname."'")."' -m -s '/bin/bash' -p '".escapeshellarg("'".$password."'")."' '".escapeshellarg("'".$loginname."'")."' \n fi' >> $tmp_conf/initramfs/postinit.local"); + $this->view->usb = true; } else{ - exec("echo 'chroot /mnt useradd -d '".escapeshellarg("'".$homepath."'")."' -m -s /bin/bash -p '".escapeshellarg("'".$password."'")."' '".escapeshellarg("'".$loginname."'")."'' >> $tmp_conf/initramfs/postinit.local",$restul); + $this->view->usb = false; if($anzUsers <= 2 && $user->getLogin() == 'kiosk' && in_array('%username%',$test) && $this->thisSession->getMembershipID() == null) - exec("echo 'chroot /mnt sed -e \"s/AutoLoginEnable=.*/AutoLoginEnable=true/g;\" /etc/kde4/kdm/kdmrc > /tmp/tmpkdmrc && sed 21iAutoLoginUser=kiosk /tmp/tmpkdmrc > /mnt/etc/kde4/kdm/kdmrc && rm /tmp/tmpkdmrc' >> $tmp_conf/initramfs/postinit.local"); - - if($anzUsers <= 2 && $user->getLogin() == '%username%') - exec("echo 'chroot /mnt sed -e \"s/AutoLoginEnable=.*/AutoLoginEnable=true/g;\" /etc/kde4/kdm/kdmrc > /tmp/tmpkdmrc && sed 21iAutoLoginUser='".escapeshellarg("'".$loginname."'")."' /tmp/tmpkdmrc > /mnt/etc/kde4/kdm/kdmrc && rm /tmp/tmpkdmrc' >> $tmp_conf/initramfs/postinit.local"); + $this->view->autologin = true; + elseif($anzUsers <= 2 && $user->getLogin() == '%username%' && $this->thisSession->getMembershipID() != null) + $this->view->autologin = true; + else + $this->view->autologin = false; } + $this->render(); + fputs($f, $this->view->script); + } } + fclose($f); // create the gzipped tarfile. chdir($tmp_conf); diff --git a/application/views/scripts/resource/getconfig.phtml b/application/views/scripts/resource/getconfig.phtml new file mode 100644 index 0000000..0e34b6e --- /dev/null +++ b/application/views/scripts/resource/getconfig.phtml @@ -0,0 +1,32 @@ +<?php + if($this->usb == true){ + $this->script =" + +modprobe usb_storage +echo -n 'Mounting OpenSLX-Stick:'; +while [ ! -e /dev/sdb1 ] do + usleep 500000 + mdev -s + echo -n . +done +mkdir -p /mnt/media/openslx-stick +mount /dev/sdb1 /mnt/media/openslx-stick +if [ -d /mnt/media/openslx-stick/boot ]; then + if [ ! -d '/mnt/media/openslx-stick/home/$this->loginname' ]; then + mkdir -p '/mnt/media/openslx-stick/home/' + chroot /mnt useradd -m -d '$this->homepath' -s /bin/bash -p '$this->password' '$this->loginname' + else + chroot /mnt useradd -d '$this->homepath' -s '/bin/bash' -p '$this->password' '$this->loginname' + fi +else + chroot /mnt useradd -d '/home/$this->loginname' -m -s '/bin/bash' -p '$this->password' '$this->loginname' +fi \n"; + + }else{ + $this->script = "chroot /mnt useradd -d '$this->homepath' -m -s /bin/bash -p '$this->password' '$this->loginname' \n"; + if($this->autologin == true){ + $this->script .= "chroot /mnt sed -e \"s/AutoLoginEnable=.*/AutoLoginEnable=true/g;\" /etc/kde4/kdm/kdmrc > /tmp/tmpkdmrc + && sed 21iAutoLoginUser='$this->loginname' /tmp/tmpkdmrc > /mnt/etc/kde4/kdm/kdmrc + && rm /tmp/tmpkdmrc \n"; + } + }
\ No newline at end of file |
