Compare commits

..

21 Commits

Author SHA1 Message Date
dfbfdcd836 Update ReadMe.md
Signed-off-by: DocRock3r <docrock3r@noreply.localhost>
2025-11-14 16:24:09 +00:00
197dc45f44 Add Scripts/Portainer-Agent.sh
Signed-off-by: DocRock3r <docrock3r@noreply.localhost>
2025-11-14 16:21:29 +00:00
9822798064 Update Scripts/Portainer-Server.sh
Signed-off-by: DocRock3r <docrock3r@noreply.localhost>
2025-11-14 16:18:17 +00:00
4e1231dd5f Update Tutorials/automount_drive_at_boot.md
Signed-off-by: DocRock3r <docrock3r@noreply.localhost>
2025-11-14 16:17:08 +00:00
a9f4ba07f4 Update Scripts/USE-AIO.sh
Signed-off-by: DocRock3r <docrock3r@noreply.localhost>
2025-11-14 15:31:40 +00:00
015ee3c6d7 Update Scripts/USE-AIO.sh
Signed-off-by: DocRock3r <docrock3r@noreply.localhost>
2025-10-21 18:28:30 +00:00
ffe4791b5b Update Scripts/USE-AIO.sh
Signed-off-by: DocRock3r <docrock3r@noreply.localhost>
2025-10-21 18:26:47 +00:00
ce94ce38c5 Update ReadMe.md
Signed-off-by: DocRock3r <docrock3r@noreply.localhost>
2025-05-16 17:00:44 +00:00
0c7e4557a8 Update Tutorials/automount_drive_at_boot.md
Signed-off-by: DocRock3r <docrock3r@noreply.localhost>
2025-05-16 16:58:49 +00:00
6078f4cd8a Update Tutorials/automount_drive_at_boot 2025-05-16 13:09:43 +00:00
4b5de0d2cb Update Tutorials/Automount_drive_at_boot 2025-05-15 15:59:36 +00:00
9443f5845e Add Tutorials/Automount-drive-at-boot 2025-05-15 15:59:10 +00:00
c3a00ba0da Update ReadMe.md 2025-05-05 14:47:13 +00:00
36bf6fc096 Update ReadMe.md 2025-05-05 14:42:56 +00:00
2025c07deb Update Tutorials/expand_drive_space.md 2025-05-05 14:37:24 +00:00
cce353aed4 Add Tutorials/expand_drive_space.md 2025-05-05 14:35:14 +00:00
92e40b866a Merge pull request 'Add change hostname script' (#3) from wip into main
Reviewed-on: #3
2025-04-23 19:47:46 +00:00
f3dffb2a74 Update Scripts/USE-AIO.sh
Signed-off-by: DocRock3r <docrock3r@noreply.localhost>
2025-04-23 19:42:52 +00:00
ff8001d297 Update Scripts/change_hostname.sh 2025-04-23 19:33:01 +00:00
86faa63db1 Update ReadMe.md
Signed-off-by: DocRock3r <docrock3r@noreply.localhost>
2025-04-23 19:16:51 +00:00
038edc961d Add Scripts/change_hostname.sh
Signed-off-by: DocRock3r <docrock3r@noreply.localhost>
2025-04-23 19:14:49 +00:00
7 changed files with 201 additions and 9 deletions

View File

@@ -1,8 +1,14 @@
# Ubuntu Server Essentials # Ubuntu Server Essentials
A collection of scripts intended to simplify setting up and maintianing an Ubuntu server A collection of scripts and tutorials intended to simplify setting up and maintianing an Ubuntu server
## Scripts ## Scripts
[All In One](Scripts/USE-AIO.sh) - All USE scripts combined together with a menu for selecting which one to run [All In One](Scripts/USE-AIO.sh) - All USE scripts combined together with a menu for selecting which one to run
[Docker](Scripts/Docker.sh) - Install Docker [Docker](Scripts/Docker.sh) - Install Docker
[Portainer](Scripts/Portainer.sh) - Install Docker and Portainer Server [Portainer Server](Scripts/Portainer-Server.sh) - Install Docker and Portainer Server
[Portainer Agent](Scripts/Portainer-Agent.sh) - Install Docker and Portianer Agent
[Update](Scripts/Update.sh) - Update and clean up unused packages [Update](Scripts/Update.sh) - Update and clean up unused packages
[Change Hostname](Scripts/change_hostname.sh) - Change the hostname for the system
## Tutorials
[Expand Drive Space](Tutorials/expand_drive_space.md)
[Mount Drive At Boot](Tutorials/automount_drive_at_boot.md)

View File

@@ -0,0 +1,25 @@
#! /bin/bash
echo "Installing Docker..."
# Add Docker's official GPG key:
sudo apt-get update 1>/dev/null
sudo apt-get install ca-certificates curl -y 1>/dev/null
sudo install -m 0755 -d /etc/apt/keyrings 1>/dev/null
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc 1>/dev/null
sudo chmod a+r /etc/apt/keyrings/docker.asc 1>/dev/null
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update 1>/dev/null
# Install Docker
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y 1>/dev/null
echo "Done"
#install Portianer agent
echo "Installing Portainer agent..."
sudo docker run -d -p 9001:9001 --name portainer_agent --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker/volumes:/var/lib/docker/volumes -v /:/host portainer/agent:lts 1>/dev/null
echo "Done" ;;

View File

@@ -4,10 +4,12 @@ clear
echo "What do you want to do?" echo "What do you want to do?"
echo "1. Install Docker" echo "1. Install Docker"
echo "2. Install Docker + Portainer Server" echo "2. Install Docker + Portainer Server"
echo "3. Update system" echo "3. Install Docker + Portianer Agent"
echo "4. Exit" echo "4. Update System"
echo "5. Change Hostname"
echo "00. Exit"
echo "" echo ""
echo -n "enter your selection: " echo -n "enter your selection(1-5)(00 to exit): "
while : while :
do do
@@ -22,12 +24,14 @@ case $choice in
sudo install -m 0755 -d /etc/apt/keyrings 1>/dev/null sudo install -m 0755 -d /etc/apt/keyrings 1>/dev/null
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc 1>/dev/null sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc 1>/dev/null
sudo chmod a+r /etc/apt/keyrings/docker.asc 1>/dev/null sudo chmod a+r /etc/apt/keyrings/docker.asc 1>/dev/null
# Add the repository to Apt sources: # Add the repository to Apt sources:
echo \ echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \ $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update 1>/dev/null sudo apt-get update 1>/dev/null
# Install Docker # Install Docker
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y 1>/dev/null sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y 1>/dev/null
echo "Done";; echo "Done";;
@@ -39,22 +43,49 @@ case $choice in
sudo install -m 0755 -d /etc/apt/keyrings 1>/dev/null sudo install -m 0755 -d /etc/apt/keyrings 1>/dev/null
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc 1>/dev/null sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc 1>/dev/null
sudo chmod a+r /etc/apt/keyrings/docker.asc 1>/dev/null sudo chmod a+r /etc/apt/keyrings/docker.asc 1>/dev/null
# Add the repository to Apt sources: # Add the repository to Apt sources:
echo \ echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \ $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update 1>/dev/null sudo apt-get update 1>/dev/null
# Install Docker # Install Docker
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y 1>/dev/null sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y 1>/dev/null
echo "Done" echo "Done"
#install Portianer server #install Portianer server
echo "Installing Portainer..." echo "Installing Portainer..."
sudo docker volume create portainer_data 1>/dev/null sudo docker volume create portainer_data 1>/dev/null
sudo docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:lts 1>/dev/null sudo docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:lts 1>/dev/null
echo "Done" ;; echo "Done" ;;
3) echo "Updating repository..." 3) echo "Installing Docker..."
# Add Docker's official GPG key:
sudo apt-get update 1>/dev/null
sudo apt-get install ca-certificates curl -y 1>/dev/null
sudo install -m 0755 -d /etc/apt/keyrings 1>/dev/null
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc 1>/dev/null
sudo chmod a+r /etc/apt/keyrings/docker.asc 1>/dev/null
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update 1>/dev/null
# Install Docker
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y 1>/dev/null
echo "Done"
#install Portianer agent
echo "Installing Portainer agent..."
sudo docker run -d -p 9001:9001 --name portainer_agent --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker/volumes:/var/lib/docker/volumes -v /:/host portainer/agent:lts 1>/dev/null
echo "Done" ;;
4) echo "Updating repository..."
sudo apt-get update 1>/dev/null sudo apt-get update 1>/dev/null
echo "Done" echo "Done"
echo "Installing updates..." echo "Installing updates..."
@@ -64,12 +95,40 @@ case $choice in
sudo apt-get autoremove -y 1>/dev/null sudo apt-get autoremove -y 1>/dev/null
echo "Done" ;; echo "Done" ;;
4) echo "Exiting..." 5) echo ""
#get current hostname and set it as value of old_host
old_host=$(hostname)
#make backups for hostname and hosts files
cp /etc/hostname /etc/hostname.bk
cp /etc/hosts /etc/hosts.bk
#ask user for new host name and set it as value for new_host
printf "%s\n" "Hostname must be between 1-63 characters long"
printf "%s\n" "Valid characters are (lower case a-z), (0-9), and (-)"
printf "%s" "enter new hostname: "
read new_host
#replace old_host with new_host in hostname and hosts files
#set hostname to new_host
sed -i 's/'$old_host'/'$new_host'/' /etc/hostname
sed -i 's/'$old_host'/'$new_host'/' /etc/hosts
hostname $new_host
#confirm change and tell user to restart system
printf "%s\n" "Hostname changed from [$old_host] to [$new_host]"
printf "%s\n" "Reboot your system for the change to take effect" ;;
00) echo "Exiting..."
exit ;; exit ;;
*) echo "Invalid option" ;; *) echo "Invalid option" ;;
esac esac
echo -n "enter your selection: " echo ""
echo ""
echo -n "enter your selection(1-5)(00 to exit): "
done done

View File

@@ -0,0 +1,26 @@
#! /bin/bash
clear
#get current hostname and set it as value of old_host
old_host=$(hostname)
#make backups for hostname and hosts files
cp /etc/hostname /etc/hostname.bk
cp /etc/hosts /etc/hosts.bk
#ask user for new host name and set it as value for new_host
printf "%s\n" "Hostname must be between 1-63 characters long"
printf "%s\n" "Valid characters are (lower case a-z), (0-9), and (-)"
printf "%s" "enter new hostname: "
read new_host
#replace old_host with new_host in hostname and hosts files
#set hostname to new_host
sed -i 's/'$old_host'/'$new_host'/' /etc/hostname
sed -i 's/'$old_host'/'$new_host'/' /etc/hosts
hostname $new_host
#confirm change and tell user to restart system
printf "%s\n" "Hostname changed from [$old_host] to [$new_host]"
printf "%s\n" "Reboot your system for the change to take effect"

View File

@@ -0,0 +1,34 @@
## 1. Find the location of the drive using `lsblk`
- ex. `/dev/sdb`
## 2. Make a new partition on the disk
1. `fdisk /dev/[location of hdd]`
- ex. `fdisk /dev/sdb`
2. `n` to make a new partiton
3. `w` to save changes
## 3. Confirm that the new partition was created
- `lsblk`
- ex. `/dev/sdb1`
## 4. Make a file system on the new partiton
- `mkfs -t ext4 /dev/[location of partition]`
- ex. `mkfs -t ext4 /dev/sdb1`
## 5. Make a directory to mount HDD to
- `sudo mkdir /mnt/hdd`
## 6. Get the UUID for the drive to be mounted
- `lsblk -fs`
## 7. Make a backup of /etc/fstab
- `sudo cp /etc/fstab /etc/fstab.bk`
- In case anything goes wrong you can restore this backup version
- `sudo cp /etc/fstab.bk /etc/fstab`
## 8. Add the new harddrive to /etc/fstab so that it is automatically mounted when the system boots
1. `sudo nano /etc/fstab`
2. add the line `UUID=[drive UUID] [mount location] ext4 defaults,auto,rw 0 0`
- ex. `UUID=4579acc6-e00d-433b-8087-0a75506e7a9c /mnt/hdd ext4 defaults,auto,rw 0 0`
## 9. Restart the system to confirm that drive mounts at boot

View File

@@ -0,0 +1,42 @@
# Add new partion and add partion to existing LVM
## 1. Add new partion using fdisk
- `sudo fdisk /dev/[drive containing partition you want to expand]`
- ex. if you want to expand partion sda3 you would use `sudo fdisk /dev/sda`
- use `p` to list partiton talble
use `F` to list free space on drive
use `n` to create a new partion
use `w` to save changes
## 2. Add new partion to existing LVM
- use `lsblk` to list all drives, partitions, and LVMs
### 2.1 Create a new physical volume (pv)
- `sudo pvcreate /dev/[partiton you want to use]`
- ex. `sudo pvcreate /dev/sda4`
### 2.2 Identify the volume group (vg) you want to use
- you can use `sudo vgs` to list all available volume groups
### 2.3 Extend volume group
- `sudo vgextend [volume group] /dev/[partition]`
- ex. `sudo vgextend ubuntu-vg /dev/sda4`
### 2.4 Identify the logical volume (lv) you want to use
- you can use `sudo lvs` to list all available logical volumes
### 2.5 Extend logical volume
- `sudo lvextend -l +100%FREE /dev/[volume group]/[logical volume]`
- ex. `sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv`
## 3. Resize filesystem so system sees changes
- `sudo resize2fs /dev/[volume group]/[logical volume]`
- ex. `sudo resize2fs/dev/ubuntu-vg/ubuntu-lv`
# Expand existing partion
1. `sudo growpart /dev/[disk] [partition number]`
- ex. `sudo growpart /dev/sda 3`
- ***note the space between disk and partion number***
2. `sudo resize2fs /dev/[partition]`
- ex. `sudo resize2fs /dev/sda3`
# Expand existing LVM to use whole partition
- `sudo lvextend -l +100%FREE /dev/[volume group]/[logical volume]`
- ex. `sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv`