-
-
Save nicnocquee/9209239dba40851d41c4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SCREEN=$(which screen) | |
if [ "$SCREEN" = "" ] | |
then | |
echo "Install screen then rerun" | |
exit 0 | |
fi | |
if [ "$STY" = "" ] | |
then | |
echo "Start screen then rerun" | |
exit 0 | |
fi | |
read -e -p "Enter username: " USERNAME | |
read -e -p "Enter user's email: " EMAIL | |
echo -n "Updating apt repositories" | |
apt-get update | |
echo "FINISHED updating apt repositories" | |
echo "Installing vim, git, incron, screen" | |
apt-get install vim git-core incron screen | |
echo "FINISHED installing vim, git, incron, screen" | |
echo -n "Set up git client..." | |
git config --global user.name "Jaisen Mathai" | |
git config --global user.email [email protected] | |
echo "OK" | |
echo -n "Move dpkg info files to /tmp..." | |
mv /var/lib/dpkg/info/wd-*.* /tmp/ | |
echo "OK" | |
echo -n "Copy sources.list from AWS..." | |
curl -k -s -S https://s3.amazonaws.com/files.trovebox.com/nas/sources.list > /etc/apt/sources.list | |
echo "OK" | |
echo "Updating apt repositories (again)" | |
apt-get update | |
echo "FINISHED updating apt repositories (again)" | |
echo "Installing required packages" | |
apt-get install php5-curl php5-mcrypt mysql-server php5-mysql php5-imagick exiftran | |
echo "FINISHED installing required packages" | |
echo -n "Copying virtualhost file from S3..." | |
curl -k -s -S https://s3.amazonaws.com/files.trovebox.com/nas/000-tbx > /etc/apache2/sites-available/000-tbx | |
echo "OK" | |
echo -n "Updating virtualhost name in config" | |
sed "s/USERNAME/$USERNAME/g" /etc/apache2/sites-available/000-tbx > /etc/apache2/sites-available/000-tbx | |
echo "Copying RSA keys from 192.168.1.139" | |
scp [email protected]:~/.ssh/id_* ~/.ssh/ | |
echo "FINISHED copying RSA keys" | |
echo "Creating MySql database" | |
mysql -u root -p -e "create database trovebox;" | |
echo "FINISHED creating MySql database" | |
echo "Enabling virtualhost..." | |
ln -s /etc/apache2/sites-available/000-tbx /etc/apache2/sites-enabled/000-tbx | |
echo "OK" | |
echo "Setting up and checking out git code" | |
cd /var/www/ | |
git clone [email protected]:photo/frontend.git tbx | |
cd tbx | |
git checkout -b 4.0.2-rc2 | |
git pull origin 4.0.2-rc2 | |
git remote add nas [email protected]:jmathai/frontend.git | |
git checkout -b nas | |
git pull nas nas | |
echo "FINISHED setting up and checking out code" | |
echo -n "Downloading override.ini..." | |
curl -k -s -S https://s3.amazonaws.com/files.trovebox.com/nas/override.ini > src/configs/override.ini | |
echo "OK" | |
echo -n "Removing remote 'origin'..." | |
sed 's/"origin"/"origin-xxx"/g' .git/config > .git/config | |
echo "OK" | |
echo -n "Creating directories and setting up permissions..." | |
mkdir src/userdata | |
chown -R www-data:www-data .. | |
ln -s /DataVolume/shares/Public/Shared\ Pictures /var/www/tbx/src/html/photos | |
echo "OK" | |
echo "Checking out nas-watch" | |
cd ~/ | |
git clone [email protected]:jmathai/nas-watch.git | |
cd nas-watch | |
chmod u+x watch.php | |
git submodule init | |
git submodule update | |
echo -n "Settup up ~/nas-watch/.credentials..." | |
curl -k -s -S https://s3.amazonaws.com/files.trovebox.com/nas/.credentials > /root/nas-watch/.credentials | |
sed "s/USERNAME/$USERNAME/g" /root/nas-watch/.credentials > /root/nas-watch/.credentials | |
echo "OK" | |
echo "Inserting dummy credentials" | |
mysql -u root -p -e "use trovebox; insert into credential values('1','$EMAIL','$EMAIL','Fake','','1','1','1','','','access',1,0);" | |
echo -n "Setting up apache configurations..." | |
a2dissite wdnas-rest-api | |
a2dissite wdnas-ui | |
a2enmod rewrite deflate expires headers | |
echo "OK" | |
echo -n "Setting up crontab..." | |
echo "*/5 * * * * /root/noip.sh ${USERNAME}.noip.me > /tmp/dns-update.log | |
*/1 * * * * /root/nas-watch/watch.php /DataVolume/shares/Public/Shared\ Pictures/upload > /tmp/watch.log" > /etc/cron.d/watch.cron | |
echo "OK" | |
echo -n "Creating upload directory..." | |
mkdir /DataVolume/shares/Public/Shared\ Pictures/upload | |
chown www-data:www-data /DataVolume/shares/Public/Shared\ Pictures/upload | |
echo "OK" | |
echo "Restarting apache" | |
/etc/init.d/apache2 restart | |
echo "Stopping wdmcserver" | |
/etc/init.d/wdmcserverd stop | |
echo "Stopping Twonky" | |
/etc/init.d/twonky stop | |
echo "" | |
echo "=====================================" | |
echo "" | |
echo "Finished automated tasks" | |
cat << STR | |
************************************************* | |
* | |
* Add this to /etc/apache2/apache2.conf | |
* IncludeOptional ${SERVER_ROOT}/sites-enabled/000-tbx | |
* | |
* comment out SSL in /etc/apache2/conf.d/additional-httpd.conf | |
* | |
* check /etc/php5/apache2/php.ini (create if needed) | |
************************************************* | |
STR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment