Created
November 20, 2017 22:10
-
-
Save keyesdav/d792814be7d9206a1924df9cc7f06d99 to your computer and use it in GitHub Desktop.
Startup script associated with a google compute engine VM instance to install, initialize, and start a Lisk node
This file contains hidden or 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
| { | |
| "canIpForward": false, | |
| "cpuPlatform": "Intel Haswell", | |
| "creationTimestamp": "2017-11-20T05:44:33.666-08:00", | |
| "deletionProtection": false, | |
| "description": "", | |
| "disks": [ | |
| { | |
| "autoDelete": true, | |
| "boot": true, | |
| "deviceName": "uncartel-001", | |
| "index": 0, | |
| "interface": "SCSI", | |
| "kind": "compute#attachedDisk", | |
| "licenses": [ | |
| "projects/ubuntu-os-cloud/global/licenses/ubuntu-1604-xenial" | |
| ], | |
| "mode": "READ_WRITE", | |
| "source": "projects/uncartel/zones/us-east1-b/disks/uncartel-001", | |
| "type": "PERSISTENT" | |
| } | |
| ], | |
| "id": "REDACTED", | |
| "kind": "compute#instance", | |
| "labelFingerprint": "REDACTED=", | |
| "machineType": "projects/uncartel/zones/us-east1-b/machineTypes/g1-small", | |
| "name": "uncartel-001", | |
| "networkInterfaces": [ | |
| { | |
| "accessConfigs": [ | |
| { | |
| "kind": "compute#accessConfig", | |
| "name": "External NAT", | |
| "natIP": "REDACTED", | |
| "type": "ONE_TO_ONE_NAT" | |
| } | |
| ], | |
| "fingerprint": "REDACTED", | |
| "kind": "compute#networkInterface", | |
| "name": "nic0", | |
| "network": "projects/uncartel/global/networks/default", | |
| "networkIP": "REDACTED", | |
| "subnetwork": "projects/uncartel/regions/us-east1/subnetworks/default" | |
| } | |
| ], | |
| "scheduling": { | |
| "automaticRestart": false, | |
| "onHostMaintenance": "TERMINATE", | |
| "preemptible": false | |
| }, | |
| "selfLink": "projects/uncartel/zones/us-east1-b/instances/uncartel-001", | |
| "serviceAccounts": [ | |
| { | |
| "email": "REDACTED", | |
| "scopes": [ | |
| "https://www.googleapis.com/auth/cloud-platform" | |
| ] | |
| } | |
| ], | |
| "startRestricted": false, | |
| "status": "RUNNING", | |
| "tags": { | |
| "fingerprint": "REDACTED" | |
| }, | |
| "zone": "projects/uncartel/zones/us-east1-b", | |
| "metadata": { | |
| "kind": "compute#metadata", | |
| "fingerprint": "REDACTED", | |
| "items": [ | |
| { | |
| "key": "startup-script-url", | |
| "value": "gs://lisk-scripts/startup.sh" | |
| }, | |
| { | |
| "key": "shutdown-script-url", | |
| "value": "gs://lisk-scripts/shutdown.sh" | |
| } | |
| ] | |
| } | |
| } |
This file contains hidden or 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 | |
| if [[ -f "/etc/redhat-release" ]]; then | |
| yum update | |
| yum install curl wget tar sudo unzip zip | |
| elif [[ -f "/etc/debian_version" ]]; then | |
| apt-get update | |
| apt-get -y install curl wget tar sudo unzip zip pwgen | |
| fi | |
| # check to see if lisk has been installed already | |
| if [[ -d "/home/lisk" ]]; then | |
| echo "Lisk is already installed. Starting Lisk..." | |
| LPW=`pwgen -N1` | |
| echo lisk:$LPW | /usr/sbin/chpasswd | |
| echo $LPW | sudo -i -u lisk bash /home/lisk/lisk-main/lisk.sh start | |
| exit | |
| else | |
| echo "Lisk not detected. Installing..." | |
| useradd -d /home/lisk -m lisk | |
| groupadd sudo | |
| usermod -a -G sudo lisk | |
| LPW=`pwgen -N1` | |
| echo lisk:$LPW | /usr/sbin/chpasswd | |
| echo "%sudo ALL=(ALL:ALL) ALL" >> /etc/sudoers | |
| if [[ -f "/etc/redhat-release" ]]; then | |
| localedef -v -c -i en_US -f UTF-8 en_US.UTF-8 | |
| localectl set-locale LANG=en_US.UTF-8 | |
| elif [[ -f "/etc/debian_version" ]]; then | |
| locale-gen en_US.UTF-8 | |
| update-locale LANG=en_US.UTF-8 | |
| fi | |
| ############# | |
| # use this if you are generating your own backups and storing them in google storage buckets | |
| #echo $LPW | sudo -i -u lisk gsutil cp `gsutil ls -lh gs://lisk-backups | awk '/gs:/{print $4}' | tail -n 1` blockchain.db.gz | |
| #echo $LPW | sudo -i -u lisk bash installLisk.sh install -r main -h -u file:///home/lisk | |
| echo $LPW | sudo -i -u lisk wget https://downloads.lisk.io/lisk/main/installLisk.sh | |
| echo $LPW | sudo -i -u lisk bash installLisk.sh install -r main -h -u https://lisktools.io/backups/ | |
| fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment