Skip to content

Commit

Permalink
gce major
Browse files Browse the repository at this point in the history
  • Loading branch information
MrDoobPG authored and MrDoobPG committed Dec 7, 2019
1 parent 714b338 commit 174d128
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 58 deletions.
48 changes: 42 additions & 6 deletions menu/gce/blitzgce.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,25 @@ source /opt/blitzgce/functions/ip.sh
source /opt/blitzgce/functions/deploy.sh
source /opt/blitzgce/functions/destroy.sh

# BAD INPUT
badinput() {
echo
read -p '⛔️ ERROR - BAD INPUT! | PRESS [ENTER] ' typed </dev/tty
gcestart
}
sudocheck() {
if [[ $EUID -ne 0 ]]; then
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⛔️ You Must Execute as a SUDO USER (with sudo) or as ROOT!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
exit 1
fi
}

### the primary interface for GCE
gcestart() {

Expand Down Expand Up @@ -45,9 +64,13 @@ gcestart() {
[ 3 } Processor Count : [ $processor ]
[ 4 ] Ram Count : [ $ramcount ]
[ 5 ] NVME Count : [ $nvmecount ]
[ 6 ] Set IP Region / Server: [ $ipaddress ] | [ $ipregion ]
[ 7 ] Deploy GCE Server : [ $gcedeployedcheck ]
[ 8 ] SSH into the GCE Box
[ 6 ] OS Image : [ $imagecount ] | [ $osdrive ]
[ 7 ] Set IP Region / Server: [ $ipaddress ] | [ $ipregion ]
[ 8 ] Deploy GCE Server : [ $gcedeployedcheck ]
[ 9 ] SSH into the GCE Box
[ C ] Calculator
[ A ] Destroy Server
Expand Down Expand Up @@ -91,15 +114,20 @@ EOF
;;
6)
projectdeny
regioncenter
imagecount
gcestart
;;
7)
projectdeny
deployserver
regioncenter
gcestart
;;
8)
projectdeny
deployserver
gcestart
;;
9)
projectdeny
if [[ "$gcedeployedcheck" == "DEPLOYED" ]]; then
sshdeploy
Expand All @@ -117,6 +145,14 @@ EOF
destroyserver
gcestart
;;
c)
calculator
gcestart
;;
C)
calculator
gcestart
;;
z)
exit
;;
Expand All @@ -128,5 +164,5 @@ EOF
;;
esac
}

sudocheck
gcestart
7 changes: 5 additions & 2 deletions menu/gce/functions/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ EOF
### Recalls Variables
variablepull

### Deploys the PG Template
### Deploys the PTS Template
gcloud compute instance-templates create pg-gce-blueprint \
--custom-cpu $processor --custom-memory $ramcount \
--image-family ubuntu-1804-lts --image-project ubuntu-os-cloud \
--image-family $osdrive --image-project $imagecount \
--boot-disk-auto-delete --boot-disk-size 200GB \
$(tail /var/plexguide/deploy.nvme)

Expand All @@ -87,6 +87,9 @@ EOF
# --custom-cpu $processor --custom-memory $ramcount \
# --image-family ubuntu-1804-lts --image-project ubuntu-os-cloud \
# --boot-disk-auto-delete --boot-disk-size 200GB \
####note --image-family ubuntu-1804-lts --image-project gce-uefi-images
#### for shielded vms with ram/drive secure boot


### Deploy the GCE Server
echo
Expand Down
14 changes: 11 additions & 3 deletions menu/gce/functions/destroy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ EOF
EOF

gcloud compute instances delete pg-gce --zone $ipzone --quiet
gcloud compute instances delete pg-gce --zone $ipzone --quiet

tee <<-EOF
Expand All @@ -47,12 +47,20 @@ EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
ipregion=$(cat /var/plexguide/project.ipregion)
gcloud compute addresses delete pg-gce --region $ipregion --quiet
rm -rf /var/plexguide/project.zone
rm -rf /var/plexguide/project.ipregion
rm -rf /var/plexguide/project.ipaddress
gcloud compute addresses delete pg-gce --region $ipregion --quiet
rm -rf /root/.ssh/google_compute_engine 1>/dev/null 2>&1

echo NOT-SET >/var/plexguide/project.ipregion
echo NOT-SET >/var/plexguide/project.ipzone
echo NOT-SET >/var/plexguide/project.processor
echo NOT-SET >/var/plexguide/project.ram
echo NOT-SET >/var/plexguide/project.nvme
echo NOT-SET >/var/plexguide/project.imagecount
echo NOT-SET >/var/plexguide/project.image

tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Expand Down
115 changes: 83 additions & 32 deletions menu/gce/functions/interface.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ EOF

}

badinput() {
echo
read -p '⛔️ ERROR - BAD INPUT! | PRESS [ENTER] ' typed </dev/tty
projectinterface
}

deployfail() {

gcefail="off"
Expand All @@ -41,8 +47,10 @@ deployfail() {
fail2=$(cat /var/plexguide/project.processor)
fail3=$(cat /var/plexguide/project.account)
fail4=$(cat /var/plexguide/project.nvme)
fail5=$(cat /var/plexguide/project.ram)
fail6=$(cat /var/plexguide/project.imagecount)

if [[ "$fail1" == "NOT-SET" || "$fail2" == "NOT-SET" || "$fail3" == "NOT-SET" || "$fail4" == "NOT-SET" ]]; then
if [[ "$fail1" == "NOT-SET" || "$fail2" == "NOT-SET" || "$fail3" == "NOT-SET" || "$fail4" == "NOT-SET" || "$fail5" == "NOT-SET" || "$fail6" == "NOT-SET" ]]; then
gcefail="on"
fi

Expand All @@ -53,22 +61,48 @@ deployfail() {
🌎 Deployment Checks Failed!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Failed to set the processer/nvme or ram count, log in, and/or set your server
location! Ensure that everything is set before deploying the GCE Server!
Unfortunately, the deploy failed,
some variables have probably not been changed, please check it
INSTRUCTIONS:
possible mistakes are
NVME / CPU / RAM / OS image / IP Region / Project Account
Quit Being a BoneHead and Read!
were not changed to desire
Ensure that everything is set before deploying the GCE Server!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
read -p '↘️ Acknowledge Being a BoneHead | Press [ENTER] ' typed </dev/tty
read -p '↘️ Acknowledge | Press [ENTER] ' typed </dev/tty

gcestart
fi
}

calculator () {
clear
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 GCE Calculaor
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
if they want to know what an instance would cost them; click on this link,
https://cloud.google.com/products/calculator/
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF

echo
read -p 'Confirm Info | PRESS [ENTER] ' typed </dev/tty
clear

gcestart
}

nvmecount() {
tee <<-EOF
Expand All @@ -80,9 +114,9 @@ Most users will only need to utilize 1 - 2 NVME Drives.
The more, the faster the processing, but the faster your credits drain.
If intent is to be in beast mode during the GCEs duration.
INSTRUCTIONS: Set the NVME Count ~ 1 / 2 / 3 / 4
INSTRUCTIONS: Set the NVME Count ~ 1 - 4
NOTE : if you use 1- 3 Nvmes you will get a swraid0
NOTE : if you use 1 - 3 Nvmes you will get a swraid0
NOTE : if you use 4 Nvmes you will get a swraid5
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Expand All @@ -96,21 +130,19 @@ EOF
touch $nvmedeploy

if [[ "$typed" == "1" ]]; then
echo "$typed" >/var/plexguide/project.nvme
echo -e "$typed" >/var/plexguide/project.nvme
echo -e "--local-ssd interface=nvme" >$nvmedeploy
elif [[ "$typed" == "2" ]]; then
echo "$typed" >/var/plexguide/project.nvme
echo -e "$typed" >/var/plexguide/project.nvme
echo -e "--local-ssd interface=nvme \\n--local-ssd interface=nvme" >$nvmedeploy
elif [[ "$typed" == "3" ]]; then
echo "$typed" >/var/plexguide/project.nvme
echo -e "$typed" >/var/plexguide/project.nvme
echo -e "--local-ssd interface=nvme \\n--local-ssd interface=nvme \\n--local-ssd interface=nvme" >$nvmedeploy
elif [[ "$typed" == "4" ]]; then
echo "$typed" >/var/plexguide/project.nvme
echo -e "$typed" >/var/plexguide/project.nvme
echo -e "--local-ssd interface=nvme \\n--local-ssd interface=nvme \\n--local-ssd interface=nvme \\n--local-ssd interface=nvme" >$nvmedeploy
elif [[ "$typed" -gt "4" ]]; then
echo "more then 4 NVME's is not possible" && sleep 5 && nvmecount
elif [[ "$typed" == "Z" || "z" || "q" || "Q" || "c" || "C" ]]; then
echo "no changes" #fi
else nvmecount; fi
}
ramcount() {
Expand All @@ -124,19 +156,44 @@ Most users will only need to utilize 8 Gb Ram.
Then more, the faster the processing, but the faster your credits drain.
If intent is to be in beast mode during the GCEs duration.
INSTRUCTIONS: Set the RAM Count ~ 8 / 12 / 16 GB
INSTRUCTIONS: Set the RAM Count ~ 8 - 64 GB
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
read -p 'Type Number | Press [ENTER]: ' typed </dev/tty

if [[ "$typed" -lt "8" || "$typed" -gt "64" ]]; then ramcount; fi

echo -e "$typed""$suffix" >/var/plexguide/project.ram
}

imagecount() {
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🌎 OS Image
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
[ 1 ] Ubuntu 1804 = Public OS Image
[ 2 ] Ubuntu 1804 = Shielded OS Image
if dont know what this means klick the link below
https://cloud.google.com/compute/docs/images
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
read -p 'Type Number | Press [ENTER]: ' typed </dev/tty

if [[ "$typed" == "8" || "$typed" == "12" || "$typed" == "16" ]]; then
echo "$typed""$suffix" >/var/plexguide/project.ram
elif [[ "$typed" -gt "16" ]]; then
echo "more then 16 Gb Ram is not possible" && sleep 5 && ramcount
elif [[ "$typed" == "Z" || "z" || "q" || "Q" || "c" || "C" ]]; then
echo "no changes" #fi
else ramcount; fi
if [[ "$typed" == "1" ]]; then
echo -e "ubuntu-os-cloud" >/var/plexguide/project.imagecount
echo -e "ubuntu-minimal-1804-lts" >/var/plexguide/project.image
elif [[ "$typed" == "2" ]]; then
echo -e "gce-uefi-images" >/var/plexguide/project.imagecount
echo -e "ubuntu-1804-lts" >/var/plexguide/project.image
else imagecount; fi
}

processorcount() {
Expand All @@ -153,20 +210,16 @@ If usage is light, select 4.
If for average use, 4 or 6 is fine.
Only utilize 8 if the GCE will be used heavily!
INSTRUCTIONS: Set the Processor Count ~ 4 / 6 / 8
INSTRUCTIONS: Set the Processor Count ~ 4 - 16 vCores
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
read -p 'Type Number | Press [ENTER]: ' typed </dev/tty

if [[ "$typed" == "4" || "$typed" == "6" || "$typed" == "8" ]]; then
echo "$typed" >/var/plexguide/project.processor
elif [[ "$typed" -gt "8" ]]; then
echo "more then 8 CPU's is not possible" && sleep 5 && processorcount
elif [[ "$typed" == "Z" || "z" || "q" || "Q" || "c" || "C" ]]; then
echo "no changes" #fi
else processorcount; fi
if [[ "$typed" -lt "4" || "$typed" -gt "16" ]]; then processorcount; fi

echo -e "$typed" >/var/plexguide/project.processor
}

projectinterface() {
Expand Down Expand Up @@ -412,8 +465,6 @@ EOF
gcestart
;;
*)
processorcount
nvmecount
;;
esac

Expand Down
3 changes: 3 additions & 0 deletions menu/gce/functions/ip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
# GNU: General Public License v3.0
################################################################################
source /opt/blitzgce/functions/main.sh
##note remove duplicate ips / regions
##rm -rf /var/plexguide/project.ipregion
##rm -rf /var/plexguide/project.ipaddress

regioncenter() {

Expand Down
10 changes: 7 additions & 3 deletions menu/gce/functions/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ variablepull() {
variable /var/plexguide/project.ipaddress NOT-SET
variable /var/plexguide/project.ipregion NOT-SET
variable /var/plexguide/project.ipzone NOT-SET
variable /var/plexguide/project.processor 2
variable /var/plexguide/project.ram 8
variable /var/plexguide/project.nvme 1
variable /var/plexguide/project.processor NOT-SET
variable /var/plexguide/project.ram NOT-SET
variable /var/plexguide/project.nvme NOT-SET
variable /var/plexguide/project.imagecount NOT-SET
variable /var/plexguide/project.image NOT-SET
variable /var/plexguide/project.id NOT-SET
variable /var/plexguide/project.switch off

Expand All @@ -38,6 +40,8 @@ variablepull() {
nvmecount=$(cat /var/plexguide/project.nvme)
ramcount=$(cat /var/plexguide/project.ram)
processor=$(cat /var/plexguide/project.processor)
imagecount=$(cat /var/plexguide/project.imagecount)
osdrive=$(cat /var/plexguide/project.image)

# if user switches usernames, this turns on. turns of when user sets project again
switchcheck=$(cat /var/plexguide/project.switch)
Expand Down
Loading

0 comments on commit 174d128

Please sign in to comment.