GO_LATEST_VERSION=# Add the latest Go version herecd~/wgethttps://go.dev/dl/go${GO_LATEST_VERSION}.linux-amd64.tar.gzsudorm-rf/usr/local/go&&sudotar-C/usr/local-xzfgo${GO_LATEST_VERSION}.linux-amd64.tar.gzexport PATH=$PATH:/usr/local/go/binecho'PATH="$PATH:/usr/local/go/bin"'>>~/.profile
Start the service and check it's working as expected.
Geth - Command Aliases
daemon-reload# Reload any changes made to the geth.servicegeth-enable# Enable the geth.servicegeth-start# Start the geth.servicegeth-status# View the status of the geth.servicegeth-log# View the geth.service logs
Geth - Update Scripts
Create Geth update script.
vim~/geth-update.sh
~/geth-update.sh
#!/bin/bashset-ewhiletrue; doread-p"Are you sure you want to update Geth? (Y/N) "yncase $yn in[Yy]*)break;;[Nn]*)exit;;* )echo"Please answer Y or N.";;esacdonecd~/go-ethereumread-p"Enter the commit hash you want to checkout: "commit_hashgitfetchgitcheckout $commit_hashechoecho"**************"echo"Making Geth..."echo"**************"makegeth# Check if geth.service is runningservice_was_running=0ifsudosystemctlis-active--quietgeth.service; then service_was_running=1echo"****************"echo"Stopping Geth..."sudosystemctlstopgeth.servicefiecho"Replacing previous version..."sudorm-rf/usr/local/bin/gethsudocp~/go-ethereum/build/bin/geth/usr/local/bin# Only start geth.service if it was running originallyif [ $service_was_running -eq1 ]; thenecho"Restarting Geth..."echo"******************"sudosystemctlstartgeth.servicefi
Make the script executable.
chmodu+x~/geth-update.sh
Geth - Configure JavaScript Console
Use --preload to load pre-written commands and functions stored in a script file.