Skip to content

Instantly share code, notes, and snippets.

@insanedefaults
Created January 13, 2016 17:42
#!/bin/bash
echo beginnning
# Colors
red='\x1b[0;31m'
yellow='\x1b[0;33m'
green='\x1b[0;32m'
teal='\x1b[0;36m'
blue='\x1b[0;34m'
purple='\x1b[0;35m'
NC='\x1b[0m' # No Color
# More stuff
printf "\nHi! Are you ready to install ${red}RedShell${NC}???\n"
printf "Of course you are.\n\n"
printf "Please enter your SSH username (with the _): "
read sshuser
rs_pod=10185
echo "step 1"
if [[ $sshuser != *"_" ]]; then
echo "Well, you forgot the _, but that's cool, I'll add it."
sshuser="${sshuser}_"
fi
echo "step 2"
printf "\n${yellow}Okay, just to confirm, is this your SSH user?\n\n${red}$sshuser\n\n${yellow}(y/n)${NC} "
read confirm_user
echo "step 3"
case $confirm_user in
[yY]) printf "\nCool beans, let's do this.\n" ;;
*) printf "\nWell try again I suppose, or not.\n\n"
exit;;
esac
echo "step 4"
mv ~/.bash_profile{,-prered} 2>/dev/null
mv ~/redshell{,-pre1} 2>/dev/null
echo "step 5"
echo "source ~/redshell/.rsh_local" > ~/.bash_profile
echo "step 6"
printf "\n\n"
echo "step 7"
rsync -arz -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet" --exclude='.git*' $sshuser@pod-$rs_pod.wpengine.com:${site_content_live_path}/redshell/core/redshell/ ~/redshell/
echo "step 8"
# Ensure perms
chmod 755 ~/redshell
find ~/redshell/ -type f -exec chmod 644 {} \;
find ~/redshell/ -type d -exec chmod 755 {} \;
sed -i "" "s/dbennett_/$sshuser/" ~/redshell/sshuser
sed -i "" "s/acurtis_/$sshuser/" ~/redshell/sshuser
echo "step 9"
printf "\n\n${red}==============================${NC}\n\n"
printf "${teal}Done!\n\n"
printf "\n${yellow}The following local file/folder changes have been made for backup reasons:\n"
printf "${purple}~/.bash_profile renamed ~/.bash_profile-prered\n"
printf "~/redshell/ renamed ~/redshell-pre1/\n\n${NC}"
printf "Future updates will be pushed out to you automatically.\n"
printf "See ${teal}http://redshell.wpengine.com${NC} for documentation.\n\n"
printf "Now just run this command:\n"
printf "${purple}source ~/.bash_profile${NC}\n\n"
printf "or just close out your terminal and open it back up.\n\n\n"
printf "${red}Have fun!${NC}\n\n\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment