/mita_automation

this is the script to deploy everything on one command

Primary LanguageShell

Create disks and mount them

prerequisites

  1. 3GB disk for swap
  2. 20GB disk for /var

how to create swap disk

1. Create a disk with 3GB size this part is mostly done by your cloud provider
2. Create a partition with 3GB size If the disk is not yet partitioned, you'll need to create a partition on it. Use fdisk or another partitioning tool to create the partition.
sudo fdisk /dev/sdx

Follow the interactive prompts to create a partition, and set its type to 'Linux swap' (usually type code 82).

3. Create a swap file system on the partition After creating the partition, you'll need to create a swap file system on it.
sudo mkswap /dev/sdx1
4. Add the partition to fstab After creating the swap file system, you'll need to add an entry to /etc/fstab so that the system will use the partition for swap each time it boots.
sudo nano /etc/fstab

Add the following line to the end of the file:

/dev/sdx1 swap swap defaults 0 0
5. Enable swap After adding the entry to /etc/fstab, you'll need to enable the swap partition.
sudo swapon -a
6. Check if swap is enabled After enabling the swap partition, you can verify that it's enabled by checking the output of the command swapon -s.
sudo swapon -s

how to create a disk for /var

1. Create a disk with 20GB size this part is mostly done by your cloud provider
2. Create a partition with 20GB size If the disk is not yet partitioned, you'll need to create a partition on it. Use fdisk or another partitioning tool to create the partition.
sudo fdisk /dev/sdx

Follow the interactive prompts to create a partition, and set its type to 'LVM' (usually type code 30, we need t for that).

3. Create system file

We need to give a system file to the partition

sudo mkfs.ext4 /dev/sdx1
4. Allocate new partition to /var
sudo mount /dev/sdx1 /var
5. Add the partition to fstab After creating the swap file system, you'll need to add an entry to /etc/fstab so that the system will use the partition for swap each time it boots.
sudo nano /etc/fstab

Add the following line to the end of the file:

/dev/sdx1 /var ext4 defaults 0 0

and finally run this command

sudo mount -a
sudo reboot

how to run the script

for running this script properly, you need to put GITHUB_TOKEN and GITHUB_USERNAME in your environment variables

cd ./etc
sudo nano environment

then add these lines to the end of the file

GITHUB_TOKEN=your_github_token
GITHUB_USERNAME=your_github_username

then press ctrl + x and then y and then enter

then you need to give the script permission to run

sudo chmod +x ./path/to/script.sh

then you can run the script

sudo ./path/to/script.sh