This is the first initial setup to be run as the root user of a brand new server for a HydraVeil Node. It sets up a Linux user, git, curl, and fixes the DNS. These can be done on your own, if you know what you’re doing or follow our guides.
63 lines
2.6 KiB
Bash
63 lines
2.6 KiB
Bash
#!/bin/bash -eu
|
|
|
|
# Ensure the script runs with root privileges
|
|
if [ "$EUID" -ne 0 ]; then
|
|
echo "Please run this script as root"
|
|
exit 1
|
|
fi
|
|
####################
|
|
sudo apt update && sudo apt upgrade
|
|
# Install curl & git for later:
|
|
sudo apt install curl git -y
|
|
############################################################################
|
|
# #
|
|
# setup a Linux user #
|
|
# #
|
|
############################################################################
|
|
read -p "Enter a linux username to make: " LINUX_USERNAME
|
|
export LINUX_USERNAME=$LINUX_USERNAME
|
|
read -p "Enter a password for $LINUX_USERNAME: " LINUX_PASSWORD
|
|
export LINUX_PASSWORD=$LINUX_PASSWORD
|
|
# setup:
|
|
useradd $LINUX_USERNAME
|
|
mkdir /home/$LINUX_USERNAME
|
|
chown $LINUX_USERNAME:$LINUX_USERNAME /home/$LINUX_USERNAME -R
|
|
# activate linux shell for the user:
|
|
look_for="/home/$LINUX_USERNAME:/bin/sh"
|
|
change_to="/home/$LINUX_USERNAME:/bin/bash"
|
|
sudo sed -i "s|$look_for|$change_to|g" /etc/passwd
|
|
# Change the password
|
|
echo "$LINUX_USERNAME:$LINUX_PASSWORD" | chpasswd
|
|
# Verify the change
|
|
if [ $? -eq 0 ]; then
|
|
echo "Password set successfully for user $LINUX_USERNAME."
|
|
else
|
|
echo "Failed to set password for user $LINUX_USERNAME."
|
|
fi
|
|
# Make a sudo user:
|
|
usermod -aG sudo $LINUX_USERNAME
|
|
############################################################################
|
|
# #
|
|
# DNS, undo google. undo cloudflare #
|
|
# #
|
|
############################################################################
|
|
sudo sed -i 's/1.1.1.1/9.9.9.9/g' /etc/network/if-up.d/custom-resolv
|
|
sudo sed -i 's/8.8.8.8/9.9.9.10/g' /etc/network/if-up.d/custom-resolv
|
|
sudo sed -i 's/1.1.1.1/9.9.9.9/g' /etc/netplan/50-cloud-init.yaml
|
|
sudo sed -i 's/8.8.8.8/9.9.9.10/g' /etc/netplan/50-cloud-init.yaml
|
|
sudo sed -i 's/1.1.1.1/9.9.9.9/g' /etc/resolv.conf
|
|
sudo sed -i 's/8.8.8.8/9.9.9.10/g' /etc/resolv.conf
|
|
sudo sudo apt install dnsutils -y
|
|
dig
|
|
read -p "do you see google or cloudflare in the above DNS servers? (yes/no): " REPLY_ON_GOOGLE_CLOUDFLARE
|
|
# Check the user's answer
|
|
if [[ "$REPLY_ON_GOOGLE_CLOUDFLARE" == "yes" ]]; then
|
|
echo "This means you need to reboot for it to take effect. Rebooting now"
|
|
reboot
|
|
elif [[ "$REPLY_ON_GOOGLE_CLOUDFLARE" == "no" ]]; then
|
|
echo "ok great. you don't need to reboot"
|
|
# switch to the user:
|
|
su $LINUX_USERNAME
|
|
else
|
|
echo "Please answer with 'yes' or 'no'."
|
|
fi
|