← Back to team overview

sslug-teknik team mailing list archive

BASH: vil ikke sammenkæde strenge

 

exec ./addsubdomain testsubdomain emailaddresse

#¡/bin/bash
echo '1'
USRNME=`whoami`
echo '2'
DOT='.'
echo '3'
MNDOMN='testwebsite.dk'
echo '4'
USRDOMN=${1}
echo '5'
LNK=""
LNK=${USRDOMN}${DOT}${USRNME}${DOT}${MNDOMN}        #<--- Denne vil ikke
give et brugbart resultat. skulle have givet LNK=
testsubdomain.brugernavn.testwebsite.dk  længere nede. Hvad gør jeg?
echo '6'
#IP="12${DOT}23${DOT}34${DOT}"
#<- Denne virker heller ikke. Hvad gør jeg?
echo '7'
DIR=${HOME}/PUBLIC_HTML
echo '8'
EMAIL=${2}
echo '9'
echo '$1=' ${1}
echo '10'
echo '$2=' ${2}
echo '11'
echo '$dot=' ${DOT}
echo '12'
echo '$usrnme=' ${USRNME}
echo '13'
echo '$MNDOMN=' ${MNDOMN}
echo '14'
echo '$USRDOMN=' ${USRDOMN}
echo '15'
echo '$LNK=' ${LNK}  <- giver som sagt et forkert udsagn.
echo '16'
echo '$ip= ' ${IP}
echo '17'
echo '$dir=' ${DIR}
echo '18'
if [ ! -d ${DIR} ] ;
then
   echo '19'
   mkdir ${HOME}/PUBLIC_HTML
fi
echo '20'
mkdir "${HOME}/PUBLIC_HTML/${LNK}"
echo '21'
mkdir "/usr/lib/cgi-bin/${LNK}"
echo '22'
echo "<VirtualHost *:80>
ServerAdmin ${EMAIL}
ServerName www.${LNK}
ServerAlias ${LNK}
DocumentRoot ${DIR}/${LNK}
 # 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}
echo '23'
a2ensite ${LNK}
echo '24'
echo '${IP}        www.${LNK}       ${LNK}' >> /etc/hosts
echo '25'
exec /etc/init.d/apache2 restart
echo '26'
quit



Follow ups