Skip to content

Commit

Permalink
mergerfs - / masterupdate roles
Browse files Browse the repository at this point in the history
  • Loading branch information
MrDoobPG authored and MrDoobPG committed Sep 15, 2019
1 parent b8b2e01 commit a2952c1
Show file tree
Hide file tree
Showing 43 changed files with 1,907 additions and 4 deletions.
131 changes: 131 additions & 0 deletions menu/gce/blitzgce.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
#!/bin/bash
#
# Title: PGBlitz (Reference Title File)
# Author(s): Admin9705 - Deiteq
# URL: https://pgblitz.com - http://github.pgblitz.com
# GNU: General Public License v3.0
################################################################################
source /opt/blitzgce/functions/main.sh
source /opt/blitzgce/functions/interface.sh
source /opt/blitzgce/functions/ip.sh
source /opt/blitzgce/functions/deploy.sh
source /opt/blitzgce/functions/destroy.sh

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

### call key variables ~ /functions/main.sh
variablepull

### For New Installs; hangs because of no account logged in yet; this prevents
othercheck=$(cat /var/plexguide/project.account)
secondcheck=$(cat /var/plexguide/project.id)
if [[ "$othercheck" != "NOT-SET" ]]; then

if [[ "$secondcheck" != "NOT-SET" ]]; then
servercheck
else
projectid=NOT-SET
gcedeployedcheck=NOT-SET
fi
else
account=NOT-SET
projectid=NOT-SET
gcedeployedcheck=NOT-SET
fi

tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🌎 PG GCE Deployment
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1. Log Into the Account : $account
2. Project Interface : $projectid
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
a. Destroy Server
z. Exit
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF

read -p 'Type Number | Press [ENTER]: ' typed </dev/tty

case $typed in
1)
echo ""
gcloud auth login --no-launch-browser --verbosity error --quiet
echo "NOT-SET" >/var/plexguide/project.id
echo "on" >/var/plexguide/project.switch
### note --no-user-output-enabled | gcloud auth login --enable-gdrive-access --brief
# gcloud config configurations list
gcestart
;;
2)
projectinterface
gcestart
;;
3)
projectdeny
processorcount
gcestart
;;

4)
projectdeny
ramcount
gcestart
;;
5)
projectdeny
nvmecount
gcestart
;;
6)
projectdeny
regioncenter
gcestart
;;
7)
projectdeny
deployserver
gcestart
;;
8)
projectdeny
if [[ "$gcedeployedcheck" == "DEPLOYED" ]]; then
sshdeploy
else
gcestart
fi
;;
A)
projectdeny
destroyserver
gcestart
;;
a)
projectdeny
destroyserver
gcestart
;;
z)
exit
;;
Z)
exit
;;
*)
gcestart
;;
esac
}

gcestart
112 changes: 112 additions & 0 deletions menu/gce/functions/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#!/bin/bash
#
# Title: PGBlitz (Reference Title File)
# Author(s): Admin9705
# URL: https://pgblitz.com - http://github.pgblitz.com
# GNU: General Public License v3.0
################################################################################
source /opt/plexguide/menu/gce/functions/main.sh

deployserver() {
variablepull
### checks to make sure common variables are filled out
deployfail
### prevents deployment if one exists!
servercheck
if [[ "$gcedeployedcheck" == "DEPLOYED" ]]; then
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 ERROR: PG GCE Instance Already Detected
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
INFORMATION: The prior GCE Server must be deleted prior to deloying a
another one! Exiting!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
read -p '↘️ Acknowledge Info | Press [ENTER] ' typed </dev/tty
gcestart
fi

### deletes deployed ip if it exists for some odd reason
# ipcheck=$(gcloud compute instances list | grep pg-gce | head -n +1 | awk '{print $2}' | grep ".")
# if [[ "$ipcheck" != "" ]]; then
#tee <<-EOF

#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
#🚀 Deleting Old IP Address
#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

#EOF
#gcloud compute addresses delete pg-gce --region $ipregion --quiet
#echo
#fi

### builds plexguide firewall if it does not exist
rulecheck=$(gcloud compute firewall-rules list | grep plexguide)
if [[ "$rulecheck" == "" ]]; then
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 Creating Firewall Rules | Does Not Exist
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF

gcloud compute firewall-rules create plexguide --allow all
echo
fi

### checks for template; if it exist; it will delete it
blueprint=$(gcloud compute instance-templates list | grep pg-gce-blueprint)
if [ "$blueprint" != "" ]; then
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 Deleting Old PG Template
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
gcloud compute instance-templates delete pg-gce-blueprint --quiet
echo
fi
### Recalls Variables
variablepull

### Deploys the PG 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 \
--boot-disk-auto-delete --boot-disk-size 200GB \
$(tail /var/plexguide/deploy.nvme)

# ### Deploys the PG 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 \
# --boot-disk-auto-delete --boot-disk-size 200GB \

### Deploy the GCE Server
echo
gcloud compute instances create pg-gce --source-instance-template pg-gce-blueprint --zone $ipzone

### Assigning the IP Address to GCE Box
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 Finalizing - Assigned IP Address to Instance
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
variablepull
echo
gcloud compute instances delete-access-config pg-gce --access-config-name "external-nat" --zone $ipzone --quiet

echo
gcloud compute instances add-access-config pg-gce --access-config-name "external-nat" --zone $ipzone --address $ipaddress
echo
read -p '↘️ Process Complete | Press [ENTER] ' typed </dev/tty

}
65 changes: 65 additions & 0 deletions menu/gce/functions/destroy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/bash
#
# Title: PGBlitz (Reference Title File)
# Author(s): Admin9705
# URL: https://pgblitz.com - http://github.pgblitz.com
# GNU: General Public License v3.0
################################################################################
source /opt/plexguide/menu/gce/functions/main.sh

destroyserver() {

### checking to making sure there is a server deployed to destroy
destorycheck=$(gcloud compute instances list | grep pg-gce | head -n +1 | awk '{print $1}')
if [[ "$destorycheck" == "" ]]; then

tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🌎 SYSTEM MESSAGE: No PG-GCE Server Deployed! Exiting!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
read -p '↘️ Acknowledge Info | Press [ENTER] ' typed </dev/tty
gcestart
fi

### starting process
echo
variablepull
zone=$(gcloud compute instances list | tail -n 1 | awk '{print $2}')
#ipdelete=$(gcloud compute addresses list | grep pg-gce | head -n +1 | awk '{print $2}')

tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🌎 SYSTEM MESSAGE: Destroying Server - Can Take Awhile!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF

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

tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🌎 SYSTEM MESSAGE: Releasing IP Address
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
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

tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🌎 SYSTEM MESSAGE: Process Complete!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF

read -p '↘️ Acknowledge Info | Press [ENTER] ' typed </dev/tty
}
Loading

0 comments on commit a2952c1

Please sign in to comment.