[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [TEKNIK] Cron Job, der automatisk tilføjer subdomains ala "test.bruger.juac.dk"



Er der nogen der kan komme med koden til at adskille "~" og resten af navnet fra hinanden,sådan at man kan slette fil poster indeholdende navnet efter "~". Desuden vil jeg meget gerne have noget kode til at kunne slette en linie fra /etc/hosts der indeholder en bestemt streng.

Thomas :)

Thomas Rosendal Jensen wrote:
Er tilbage med lidt tilføjelser til scriptet og er nogenlunde kommet mig over min næse operation :)

Se: "[TEKNIK] Webhotel til undervisningsbrug vha. flere sub domains for hver elev."
Skrevet: 04-03-2011 18:17

Se: [TEKNIK] rettigheds problemer chmod + chown mfl.

Se desuden: "[TEKNIK] Fremstilling af Daemon, skrevet helt i BASH"

Har brug for vejledning til at kunne lave kode der fjerner subdomains der hedder noget ala test.bruger.juac.dk ved at brugeren omnavngiver folderen /home/bruger/PUBLIC_HTML/test til /home/bruger/PUBLIC_HTML/~test.

Vil senere lave kode der foruden dette tilføjer en MySQL database ved navn lignende test.bruger.juac.dk. Det ønskes ligeledes at den skal fjerne databasen igen ved at brugeren omnavngiver /home/bruger/PUBLIC_HTML/test -folderen
til /home/bruger/PUBLIC_HTML/~test :)


Her er så den foreløbige kode. Det er vigtigt at der skrives i bash-script:


#!/bin/bash
set -x

USERARRAY=$(ls -l --format=single-column /home/)
for USRNME in sslug@sslug
do
 USRDOMNARRAY=$(ls -l --format=single-column /home/$USRNME/PUBLIC_HTML/)
 for USRDOMN in sslug@sslug
 do
echo $USRDOMN $USRNME DOT='.'
  MNDOMN='juac.dk'
  LNK=$(echo ${USRDOMN}${DOT}${USRNME}${DOT}${MNDOMN})
  IP=$(echo 90${DOT}184${DOT}106${DOT}85)
  DIR=home/$USRNME/PUBLIC_HTML
  if [ ! -d ${DIR} ];
  then
    mkdir ${DIR}
  fi
  if [ ! -d /usr/lib/cgi-bin/${LNK}];
  then
    mkdir "/usr/lib/cgi-bin/${LNK}"
  fi
  if [ ! -d /etc/apache2/sites-available/${LNK}];
then echo "<VirtualHost *:80>
 ServerAdmin sslug@sslug
 ServerName www.${LNK}
 ServerAlias ${LNK}
 DocumentRoot ${DIR}/${USRDOMN}
  # Set Document Root directory options
  <Directory />
    Options FollowSymlnks -Indexes Includes
    # Allow use of .htaccess file
    AllowOverride Limit FileInfo
  </Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/${LNK}
  # Set CGI-BIN directory options
  <Directory /cgi-bin>
    AllowOverride None
    Options +ExecCGI -Multiviews +SymlnksIfOwnerMatch
    Order allow,deny
    Allow from all
  </Directory>
 CustomLog /var/log/apache2/access.log common
 ErrorLog /var/log/apache2/error.log
</VirtualHost>" > /etc/apache2/sites-available/${LNK}
  fi
  exec /usr/sbin/a2ensite ${LNK}
  SPACE='       '
  WWW='www'
  echo $(echo ${IP}${SPACE}${WWW}${DOT}${LNK}${SPACE}${LNK}) >> /etc/hosts
  exec /etc/init.d/apache2 reload
  done
 done

# end script




 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2011-05-01, 02:01 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *