User:Mihho/test

From IThelp
Revision as of 08:24, 20 March 2018 by Mihho (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

testing

<source lang=bash>

  1. !/bin/bash
  2. DIKULT105: lager kataloger for gruppene/prosjektene
  3. NB: katalogenen må være lesbare på nett
  4. August 2013 - BS-259848
  5. Studentens navn må anonymiseres i url'en. Dette gjøres med en autogenerert streng som knyttes til brukerens uid.
  6. Epost må sendes ut til hver enkelt student, og her burde det vel funke med username@uib.no

HOMEDIR="/var/www/kurs/dikult105-test/" DIKULTLDAPGROUPS=`ldapsearch -x -H ldap://frost.uib.no cn=vev_dikult105* | grep 'vev_dikult105_' | grep -v '#' | grep 'cn:' | sed 's/cn: //g'` DIKULT105_MEMBERS=`getent group vev_dikult105 | sed 's/vev_dikult105:\*:9290://g' | sed 's/,/ /g'` ASSIGNMENTFOLDERS="assignment1 assignment2 assignment3"

echo "cd $HOMEDIR"

for k in $DIKULTLDAPGROUPS;do

 DIKULTGROUPNAME=`echo $k | sed s/vev_//g`
 echo "mkdir $DIKULTGROUPNAME"
 echo "chown apache:$k $DIKULTGROUPNAME"
 echo "chmod 770 $DIKULTGROUPNAME"
 DIKULTGROUP_MEMBERS=`getent group $k | sed 's/vev_dikult105.*:\*:.*://g' | sed 's/,/ /g'`

done;

for j in $ASSIGNMENTFOLDERS;do

 echo "mkdir $j"
 echo "chown fafdj $j"
 echo "cd $j"
 for i in $DIKULT105_MEMBERS;do
   USERSNAME=`getent passwd $i | awk -F':' '{print \$5 }' | sed 's/ /_/g'`
   FOLDER=`./randpwgen.sh`
   echo "mkdir $FOLDER"
   echo "chown $i $FOLDER"
   echo "chmod 750 $FOLDER"
   echo "chgrp apache $FOLDER"
   echo "# Sender epost til $USERSNAME..."
   echo "echo \"Din unike kode til Dikult105 er: $FOLDER\" | mail -s \"Dikult105 kode\" $i@uib.no"
   echo $USERSNAME
 done;
 echo "cd .."

done;

</source>