Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Nächste Überarbeitung | Vorhergehende Überarbeitung Nächste Überarbeitung Beide Seiten der Revision | ||
cloud4education [2012/11/04 11:55] admin angelegt |
cloud4education [2012/11/04 14:52] admin |
||
---|---|---|---|
Zeile 3: | Zeile 3: | ||
===== Version 4.5.1 ===== | ===== Version 4.5.1 ===== | ||
+ | <code php apps/files/index.php> | ||
+ | // Check if we are a user | ||
+ | OCP\User::checkLoggedIn(); | ||
+ | OCP\User::checkHomeMounted(); | ||
+ | </code> | ||
+ | |||
+ | *Branding | ||
+ | * core/img/logo.svg | ||
+ | * core/img/logo.png | ||
+ | * core/img/favicon.svg | ||
+ | * core/img/favicon.png | ||
+ | * core/img/favicon-touch.svg | ||
+ | * core/img/favicon-touch.png | ||
+ | |||
+ | <code php core/templates/layout.guest.php> | ||
+ | <title>cloud4education</title> | ||
+ | ... | ||
+ | <img src="<?php echo image_path('', 'logo.png'); ?>" alt="cloud4education" style="width: 22em" /> | ||
+ | ... | ||
+ | <footer><p class="info"><a href="http://www.cloud4education.at/">cloud4education</a> – <?php echo $l->t( 'eine freie Cloud-Lösung für Schulen' ); ?></p></footer> | ||
+ | </code> | ||
+ | |||
+ | <code php core/templates/layout.user.php> | ||
+ | <title><?php echo isset($_['application']) && !empty($_['application'])?$_['application'].' | ':'' ?>cloud4education <?php echo OC_User::getUser()?' ('.OC_User::getUser().') ':'' ?></title> | ||
+ | </code> | ||
===== Version 4.0.1 ===== | ===== Version 4.0.1 ===== | ||
+ | <code php files/index.php> | ||
+ | // Check if we are a user | ||
+ | OC_Util::checkLoggedIn(); | ||
+ | OC_Util::checkHomeMounted(); | ||
+ | </code> | ||
+ | |||
+ | <code php lib/user.php> | ||
+ | /** | ||
+ | * @brief Kick the user | ||
+ | * @returns true | ||
+ | * | ||
+ | * Logout, destroys session | ||
+ | */ | ||
+ | public static function logout(){ | ||
+ | OC_Hook::emit( "OC_User", "logout", array()); | ||
+ | exec("sudo umount /srv/www/htdocs/".OC::$WEBROOT."/data/".OC_User::getUser()."/files/Home"); | ||
+ | foreach(self::getS4eShares() as $share) { | ||
+ | exec("sudo umount /srv/www/htdocs/".OC::$WEBROOT."/data/".OC_User::getUser()."/files/".$share); | ||
+ | } | ||
+ | // BÖSE? OC_Helper::rmdirr("/srv/www/htdocs/".OC::$WEBROOT."/data/".OC_User::getUser()); | ||
+ | OC_Helper::rmdirr("/srv/www/htdocs/".OC::$WEBROOT."/data/".OC_User::getUser()); | ||
+ | $_SESSION['user_id'] = false; | ||
+ | OC_User::unsetMagicInCookie(); | ||
+ | return true; | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | <code php lib/util.php> | ||
+ | |||
+ | /** | ||
+ | * Check if the user is logged in, redirects to home if not | ||
+ | */ | ||
+ | public static function checkLoggedIn(){ | ||
+ | // Check if we are a user | ||
+ | if( !OC_User::isLoggedIn()){ | ||
+ | header( 'Location: '.OC_Helper::linkTo( '', 'index.php' , true)); | ||
+ | exit(); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | /*** server4education ***/ | ||
+ | |||
+ | /** | ||
+ | * Check if home folder is mounted, mount if not | ||
+ | */ | ||
+ | public static function checkHomeMounted(){ | ||
+ | // Check if home folder is mounted | ||
+ | if (!OC_Filesystem::is_dir('/Home')) { | ||
+ | OC_Filesystem::mkdir('/Home'); } | ||
+ | exec("sudo /usr/local/bin/mounthome ".OC_User::getUser()." ".$_SESSION['user_password']); | ||
+ | #exec("sudo mount | grep \"on /srv/www/htdocs/owncloud/data/".OC_User::getUser()."/files/Home type\"; if [ $? -eq 1 ] ; then sudo mount //localhost/".OC_User::getUser()." /srv/www/htdocs/".OC::$WEBROOT."/data/".OC_User::getUser()."/files/Home -o user=".OC_User::getUser().",pass=".$_SESSION['user_password'].",uid=wwwrun,gid=www; fi"); | ||
+ | |||
+ | foreach(self::getS4eShares() as $share) { | ||
+ | if (!OC_Filesystem::is_dir('/'.$share)) { | ||
+ | OC_Filesystem::mkdir('/'.$share); | ||
+ | } | ||
+ | exec("sudo /usr/local/bin/mountshare ".OC_User::getUser()." ".$_SESSION['user_password']." ".$share); | ||
+ | # exec("mount | grep \"on /srv/www/htdocs/".OC::$WEBROOT."/data/".OC_User::getUser()."/files/".$share." type\" > /dev/null; if [ $? -eq 1 ] ; then sudo mount //localhost/".$share." /srv/www/htdocs/".OC::$WEBROOT."/data/".OC_User::getUser()."/files/".$share." -o user=".OC_User::getUser().",pass=".$_SESSION['user_password'].",uid=wwwrun,gid=www; fi"); | ||
+ | } | ||
+ | exec("logger \"".OC_User::getUser()." - cloud4education ".`date +%s`."\""); | ||
+ | } | ||
+ | |||
+ | /*** server4education ***/ | ||
+ | |||
+ | </code> | ||
+ | |||
+ | <code ini config/s4eshares.config> | ||
+ | gemeinsam | ||
+ | material | ||
+ | abgabe | ||
+ | </code> | ||
+ | |||
+ | <code bash /usr/local/bin/cloud4education> | ||
+ | #!/bin/bash | ||
+ | |||
+ | for username in $(mount | grep owncloud | grep Home | cut -d"/" -f4 | cut -d" " -f1); do | ||
+ | START=$(grep "logger: $username" /var/log/messages | tail -1 | awk '{print $9}') | ||
+ | DUR=$(echo "( ( $(date +%s) - $START ) / 60 )" | bc) | ||
+ | if [ $DUR -gt 15 ]; then | ||
+ | umount /srv/www/htdocs/owncloud/data/$username/files/Home | ||
+ | for SHARE in `cat /srv/www/htdocs/owncloud/config/s4eshares.config`; do | ||
+ | umount /srv/www/htdocs/owncloud/data/$username/files/$SHARE | ||
+ | done | ||
+ | rm /srv/www/htdocs/owncloud/data/$username | ||
+ | fi | ||
+ | done | ||
+ | |||
+ | </code> | ||
+ | |||
+ | <code bash /usr/local/bin/mounthome> | ||
+ | #!/bin/bash | ||
+ | |||
+ | mount | grep "on /srv/www/htdocs/owncloud/data/$1/files/Home type" > /dev/null | ||
+ | if [ $? -eq 1 ] ; then | ||
+ | sudo mount "//localhost/$1" /srv/www/htdocs/owncloud/data/$1/files/Home -o user="$1",pass="$2",uid=wwwrun,gid=www | ||
+ | fi | ||
+ | </code> | ||
+ | |||
+ | |||
+ | <code bash /usr/local/bin/mountshare> | ||
+ | #!/bin/bash | ||
+ | |||
+ | mount | grep "on /srv/www/htdocs/owncloud/data/$1/files/$3 type" > /dev/null | ||
+ | if [ $? -eq 1 ] ; then | ||
+ | sudo mount "//localhost/$3" "/srv/www/htdocs/owncloud/data/$1/files/$3" -o user="$1",pass="$2",uid=wwwrun,gid=www | ||
+ | fi | ||
+ | </code> | ||
+ | |||
+ | <code bash crontab> | ||
+ | # Umount lost cloud4education connections | ||
+ | */15 * * * * /usr/local/bin/cloud4education > /dev/null 2>&1 | ||
+ | </code> | ||
+ | |||
+ | *Branding: | ||
+ | * core/img/owncloud-logo-medium-white.png | ||
+ | * core/img/logo.svg | ||
+ | * core/img/logo.png | ||
+ | * core/img/logo-wide.svg | ||
+ | * core/img/logo-wide.png | ||
+ | |||
+ | <code php core/templates/layout.user.php> | ||
+ | <title>cloud4education</title> | ||
+ | </code> | ||
+ | |||
+ | <code php core/templates/layout.guest.php> | ||
+ | <title>cloud4education</title> | ||
+ | ... | ||
+ | <footer><p class="info"><a href="http://www.cloud4education.at/">cloud4education</a> – <?php echo $l->t( 'eine freie Cloud-Lösung für Schulen' ); ?></p></footer> | ||
+ | </code> | ||
+ | |||
+ | <code css core/templates/css/styles.css> | ||
+ | #body-login p.info { width:26em; text-align: center; margin:2em auto; color:#777; text-shadow:#fff 0 1px 0; } | ||
+ | </code> | ||
+ | <code ini /etc/sudoers> | ||
+ | wwwrun ALL = NOPASSWD: /usr/local/bin/mounthome | ||
+ | wwwrun ALL = NOPASSWD: /usr/local/bin/mountshare | ||
+ | wwwrun ALL = NOPASSWD: /bin/umount | ||
+ | wwwrun ALL = NOPASSWD: /bin/mount | ||
+ | wwwrun ALL = NOPASSWD: /sbin/mount.cifs | ||
+ | </code> |