Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2016
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.30 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. # Preserve pwd for later
  4. BASE_DIR=$(pwd)
  5.  
  6. # Setup .bash_profile
  7. read -p "Setup bash profile? [y/n] " -r
  8. if [[ $REPLY =~ ^[Yy]$ ]]
  9. then
  10.     cat bash_profile.txt > ~/.bash_profile
  11.     source ~/.bash_profile
  12. fi
  13.  
  14. if [ ! -d $MARKETLIVE_HOME ];
  15. then
  16.     # Setup marketlive directory
  17.     echo "Your marketlive home directory is not set, creating it now..."
  18.     cd ~
  19.     mkdir -p $MARKETLIVE_HOME
  20.     sudo chown $USER:staff $MARKETLIVE_HOME
  21.     mkdir -p $MARKETLIVE_HOME/sites
  22.     echo "Done"
  23. fi
  24. echo
  25.  
  26. read -p "Install homebrew and required packages? [y/n] " -r
  27. if [[ $REPLY =~ ^[Yy]$ ]]
  28. then
  29.     # Install XCode command line tools if not already installed
  30.     xcode-select --install
  31.  
  32.     # Install homebrew if not already installed
  33.     /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  34.  
  35.     # Install maven
  36.     brew install maven
  37.  
  38.     # Install rabbitmq
  39.     brew install rabbitmq
  40. fi
  41. echo
  42.  
  43. read -p "Would you like to download marketlive files? [y/n] " -r
  44. if [[ $REPLY =~ ^[Yy]$ ]]
  45. then
  46.     # Grab marketlive files from svn
  47.     # sudo svn export https://ps-svn.aws.marketlive.com/marketlive/tools $MARKETLIVE_HOME/tools --force
  48.     # sudo svn export https://ps-svn.aws.marketlive.com/marketlive/images $MARKETLIVE_HOME/images --force
  49.     # sudo svn export https://ps-svn.aws.marketlive.com/marketlive/libraries $MARKETLIVE_HOME/libraries --force
  50.     # sudo svn export https://ps-svn.aws.marketlive.com/marketlive/release $MARKETLIVE_HOME/release --force
  51.  
  52.     # Extract folders because it is faster (svn method takes > 1 hour on wifi)
  53.     unzip -o $BASE_DIR/ecom_files/ecom_tools.zip -d $MARKETLIVE_HOME
  54.     unzip -o $BASE_DIR/ecom_files/ecom_release.zip -d $MARKETLIVE_HOME
  55.     unzip -o $BASE_DIR/ecom_files/ecom_tomcat.zip -d $MARKETLIVE_HOME
  56.     unzip -o $BASE_DIR/ecom_files/ecom_images.zip -d $MARKETLIVE_HOME
  57.     unzip -o $BASE_DIR/ecom_files/ecom_libraries.zip -d $MARKETLIVE_HOME
  58.     chmod +x $MARKETLIVE_HOME/tomcat/apache-tomcat-7.0.52/bin/*
  59. fi
  60. echo
  61.  
  62. read -p "Setup mongo? [y/n] " -r
  63. if [[ $REPLY =~ ^[Yy]$ ]]
  64. then
  65.     # Setup mongo
  66.     sudo mkdir -p /data/db
  67.     sudo chmod 777 /data/db
  68.     echo "Installing mongodb"
  69.     sudo cp -R $BASE_DIR/mongo $MARKETLIVE_HOME/mongo
  70.  
  71.     echo "Installing MongoDB Launchctl Item and Restarting Mongo";
  72.  
  73.     # Create temporary org.mongo.mongod.plist file
  74.     sudo touch org.mongo.mongod.plist
  75.     sudo chmod 777 org.mongo.mongod.plist
  76.     sudo cat copy.org.mongo.mongod.plist | sed -e "s#{marketlive_home}#$MARKETLIVE_HOME#" > org.mongo.mongod.plist
  77.    
  78.     # create mongo directories
  79.     sudo chmod 777 $MARKETLIVE_HOME/mongo
  80.     mkdir -vp $MARKETLIVE_HOME/mongo/data/db
  81.     mkdir -vp $MARKETLIVE_HOME/mongo/data/log/
  82.     sudo touch $MARKETLIVE_HOME/mongo/data/log/mongodb.log
  83.  
  84.     # copy PLIST and (re)install it
  85.     sudo cp $BASE_DIR/org.mongo.mongod.plist /Library/LaunchDaemons/
  86.     sudo chown root:wheel /Library/LaunchDaemons/org.mongo.mongod.plist
  87.     launchctl stop org.mongo.mongod
  88.     launchctl unload /Library/LaunchDaemons/org.mongo.mongod.plist
  89.     launchctl load /Library/LaunchDaemons/org.mongo.mongod.plist
  90.     launchctl start org.mongo.mongod
  91.     sudo rm org.mongo.mongod.plist
  92.     echo "FINISHED";
  93. fi
  94. echo
  95.  
  96. # Edit settings files located in /.m2 directory
  97. # Setup master password in settings-security.xml
  98. # Setup nexus username and nexus password in settings.xml
  99. read -p "Set a new master password? [y/n] " -r
  100. if [[ $REPLY =~ ^[Yy]$ ]]
  101. then
  102.     mkdir -p ~/.m2
  103.     echo -n "Enter a master password for settings-security.xml: "
  104.     read -s MASTER
  105.     MASTER="$(mvn --encrypt-master-password MASTER | sed 's/\//\\\//g')"
  106.     echo "Master password set"
  107.     echo $MASTER
  108.     cat $BASE_DIR/settings-security-clean.xml | sed "s/{pass}/${MASTER}/" > ~/.m2/settings-security.xml
  109. fi
  110. echo
  111.  
  112. read -p "Set a new nexus username/password? [y/n] " -r
  113. if [[ $REPLY =~ ^[Yy]$ ]]
  114. then
  115.     echo -n "Nexus server username (ml.username): "
  116.     read NEXUS_USER
  117.     echo "Nexus username set"
  118.     echo $NEXUS_USER
  119.     echo -n "Nexus server password: "
  120.     read -s NEXUS_PASS
  121.     NEXUS_PASS="$(mvn --encrypt-password NEXUS_PASS | sed 's/\//\\\//g')"
  122.     echo "Nexus password set"
  123.     echo $NEXUS_PASS
  124.     cat $BASE_DIR/settings-clean.xml | sed -e "s/{mlUser}/${NEXUS_USER}/" | sed -e "s/{mlPass}/${NEXUS_PASS}/" > ~/.m2/settings.xml
  125. fi
  126. echo
  127.  
  128. read -p "Set up SSH key? [y/n] " -r
  129. if [[ $REPLY =~ ^[Yy]$ ]]
  130. then
  131.     ssh -o ConnectTimeout=6 root@192.168.56.101 exit
  132. fi
  133. echo
  134.  
  135. echo DONE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement