Programming is very new to me I have chosen to learn the basics using bash. I am currently working on a script that clones a wordpress install from a master template it then edits the sql database accordingly.I have different templates to choose from so I need a conditional statement which is where I am having a problem with at the moment. When I run my script it just runs everything completely disregarding my conditions. I have been doing a bunch of reading about if then and I am stuck here . Unless I am misunderstanding something along the way. If anyone can point me into the right direction it would be greatly appreciated. Thanks in advance
#!/bin/sh
sed 's/wpruser123/"$VIRTUALSERVER_USER"/g' "$VIRTUALSERVER_HOME"/public_html/wp-config1.php > tmp_file
mv tmp_file "$VIRTUALSERVER_HOME"/public_html/wp-config2.php
sed 's/wprpass123/"$VIRTUALSERVER_PASS"/g' "$VIRTUALSERVER_HOME"/public_html/wp-config2.php > tmp_file
mv tmp_file "$VIRTUALSERVER_HOME"/public_html/wp-config.php
rm "$VIRTUALSERVER_HOME"/public_html/wp-config1.php
rm "$VIRTUALSERVER_HOME"/public_html/wp-config2.php
if [ "$VIRTUALSERVER_TEMPLATE" = '149505977015116' ]; then
mysqldump trueblue > "$VIRTUALSERVER_HOME"/public_html/wprb.sql
chmod +x "$VIRTUALSERVER_HOME"/public_html/wprb.sql
sed s/trueblue.dev.example.com/"$VIRTUALSERVER_DOM"/g "$VIRTUALSERVER_HOME"/public_html/wprb.sql > tmp_file
mv tmp_file "$VIRTUALSERVER_HOME"/public_html/wprb2.sql
mysql --user="$VIRTUALSERVER_USER" --password="$VIRTUALSERVER_PASS" --database="$VIRTUALSERVER_USER" < "$VIRTUALSERVER_HOME"/public_html/wprb2.sql
fi
if [ "$VIRTUALSERVER_TEMPLATE" = '149505982215162' ]; then
mysqldump polishedpro > "$VIRTUALSERVER_HOME"/public_html/wprb.sql
chmod +x "$VIRTUALSERVER_HOME"/public_html/wprb.sql
sed s/polishedpro.dev.example.com/"$VIRTUALSERVER_DOM"/g "$VIRTUALSERVER_HOME"/public_html/wprb.sql > tmp_file
mv tmp_file "$VIRTUALSERVER_HOME"/public_html/wprb2.sql
mysql --user="$VIRTUALSERVER_USER" --password="$VIRTUALSERVER_PASS" --database="$VIRTUALSERVER_USER" < "$VIRTUALSERVER_HOME"/public_html/wprb2.sql
fi
if [ "$VIRTUALSERVER_TEMPLATE" = '149505993915397' ]; then
mysqldump luminous > "$VIRTUALSERVER_HOME"/public_html/wprb.sql
chmod +x "$VIRTUALSERVER_HOME"/public_html/wprb.sql
sed s/luminous.dev.example.com/"$VIRTUALSERVER_DOM"/g "$VIRTUALSERVER_HOME"/public_html/wprb.sql > tmp_file
mv tmp_file "$VIRTUALSERVER_HOME"/public_html/wprb2.sql
mysql --user="$VIRTUALSERVER_USER" --password="$VIRTUALSERVER_PASS" --database="$VIRTUALSERVER_USER" < "$VIRTUALSERVER_HOME"/public_html/wprb2.sql
fi
if [ "$VIRTUALSERVER_TEMPLATE" = '149505987915222' ]; then
mysqldump steadyscroll > "$VIRTUALSERVER_HOME"/public_html/wprb.sql
chmod +x "$VIRTUALSERVER_HOME"/public_html/wprb.sql
sed s/trueblue.dev.example.com/"$VIRTUALSERVER_DOM"/g "$VIRTUALSERVER_HOME"/public_html/wprb.sql > tmp_file
mv tmp_file "$VIRTUALSERVER_HOME"/public_html/wprb2.sql
mysql --user="$VIRTUALSERVER_USER" --password="$VIRTUALSERVER_PASS" --database="$VIRTUALSERVER_USER" < "$VIRTUALSERVER_HOME"/public_html/wprb2.sql
fi
if [ "$VIRTUALSERVER_TEMPLATE" = '149505991515361' ]; then
mysqldump evenkeel > "$VIRTUALSERVER_HOME"/public_html/wprb.sql
chmod +x "$VIRTUALSERVER_HOME"/public_html/wprb.sql
sed s/evenkeel.dev.example.com/"$VIRTUALSERVER_DOM"/g "$VIRTUALSERVER_HOME"/public_html/wprb.sql > tmp_file
mv tmp_file "$VIRTUALSERVER_HOME"/public_html/wprb2.sql
mysql --user="$VIRTUALSERVER_USER" --password="$VIRTUALSERVER_PASS" --database="$VIRTUALSERVER_USER" < "$VIRTUALSERVER_HOME"/public_html/wprb2.sql
fi
if [ "$VIRTUALSERVER_TEMPLATE" = '149505995815433' ]; then
mysqldump cleanslate > "$VIRTUALSERVER_HOME"/public_html/wprb.sql
chmod +x "$VIRTUALSERVER_HOME"/public_html/wprb.sql
sed s/cleanslate.dev.example.com/"$VIRTUALSERVER_DOM"/g "$VIRTUALSERVER_HOME"/public_html/wprb.sql > tmp_file
mv tmp_file "$VIRTUALSERVER_HOME"/public_html/wprb2.sql
mysql --user="$VIRTUALSERVER_USER" --password="$VIRTUALSERVER_PASS" --database="$VIRTUALSERVER_USER" < "$VIRTUALSERVER_HOME"/public_html/wprb2.sql
fi
rm "$VIRTUALSERVER_HOME"/public_html/wprb.sql
rm "$VIRTUALSERVER_HOME"/public_html/wprb2.sql
Aucun commentaire:
Enregistrer un commentaire