User:Mihho/test: Difference between revisions

From IThelp
mNo edit summary
No edit summary
Line 1: Line 1:
= University of Bergen | IT department =
<source lang=bash>
__NOTOC__
#!/bin/bash
<div class="w3-container">
# DIKULT105: lager kataloger for gruppene/prosjektene
  <div class="w3-row">
# NB: katalogenen må være lesbare på nett
    <div class="info w3-animate-left w3-sand w3-col s12 m7 l7">
# August 2013 - BS-259848
<htmlet>ithelp</htmlet>
# Studentens navn må anonymiseres i url'en. Dette gjøres med en autogenerert streng som knyttes til brukerens uid.
<hr>{{:Software}}
# Epost må sendes ut til hver enkelt student, og her burde det vel funke med username@uib.no
<hr>{{:Print services}}
<hr>{{:Services from the IT department}}
<hr>'''[[Services from the IT department|>> More IT services]]'''
    </div>
    <div class="info w3-animate-right w3-light-grey w3-col s12 m4 l4">
<rss "title=off">http://meldinger.uib.no/rss.php?meldingstype=itdrift</rss>


'''[http://meldinger.uib.no/itdrift.php?modus=arkiv >> Arkiv]'''
HOMEDIR="/var/www/kurs/dikult105-test/"
<hr>
DIKULTLDAPGROUPS=`ldapsearch -x -H ldap://frost.uib.no cn=vev_dikult105* | grep 'vev_dikult105_' | grep -v '#' | grep 'cn:' | sed 's/cn: //g'`
{{:News}}
DIKULT105_MEMBERS=`getent group vev_dikult105 | sed 's/vev_dikult105:\*:9290://g' | sed 's/,/ /g'`
'''[https://it.uib.no/Aktuelt >> Norwegian news ]'''
ASSIGNMENTFOLDERS="assignment1 assignment2 assignment3"
<hr>{{:Support}}
 
<hr>{{:Email}}
echo "cd $HOMEDIR"
<hr>{{:Private computer}}
 
     </div>
for k in $DIKULTLDAPGROUPS;do
</div>
  DIKULTGROUPNAME=`echo $k | sed s/vev_//g`
<div class="w3-row w3-animate-opacity w3-blue-grey">
  echo "mkdir $DIKULTGROUPNAME"
  <div class="w3-container">
  echo "chown apache:$k $DIKULTGROUPNAME"
  [[no:Hovedside]]
  echo "chmod 770 $DIKULTGROUPNAME"
Address: Postboks 7800 5020 Bergen
  DIKULTGROUP_MEMBERS=`getent group $k | sed 's/vev_dikult105.*:\*:.*://g' | sed 's/,/ /g'`
Visiting address: Nygårdsgaten 5
done;
Phone: (+47) 55584700
 
Fax: (+47) 55584070
for j in $ASSIGNMENTFOLDERS;do
     </div>
  echo "mkdir $j"
   </div>
  echo "chown fafdj $j"
   </div>
  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>

Revision as of 08:23, 20 March 2018

#!/bin/bash
# DIKULT105: lager kataloger for gruppene/prosjektene
# NB: katalogenen må være lesbare på nett
# August 2013 - BS-259848
# Studentens navn må anonymiseres i url'en. Dette gjøres med en autogenerert streng som knyttes til brukerens uid.
# 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;