Analytics request

The analytics will make Airikr Blog better. If you accept the analytics request, the following data will be stored about you:

  • The device's IP address
  • Browser's user agent
  • What pages you visit
  • A timestamp when you agreed to the analytics
  • A timestamp for each page you've visited

Read more on how the website uses your data.

Showing posts with the tag "install"

My backup/restore and install bash scripts

_
Cover

After I finally installed Linux Mint 20.2 Cinnamon and used my install.sh script, I fine-tuned the script to my needs since I'd missed to add a lot. Shortly after, I started to write a backup bash script. I have written such bash script for my Linux setup before, but they were not good. I thought I backup the files to Backblaze B2 Cloud Storage, but it felt more natural to just backup the files to my external HDD.

Instead of having my bash scripts on a git page like Codeberg, I have them on my personal wiki which is a self-hosted BookStack. And since version 20.2 of Linux Mint Cinnamon have WebApps, I have added Airikr Wiki to my taskbar. Perfect!

Since I am a total newbie to bash, my scripts might look very amateurish. But I am a learner and might improve my scripts along the way.

I love how simple it is to pass a command to to the bash script by running backtore.sh backup to run the backup process and backtore.sh restore to run the restore.

install.sh

#!/bin/bash

echo 'alias update="sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get autoclean -y && sudo apt-get autoremove -y && sudo apt-get clean"
alias listapps="sudo apt list --installed"
alias myip="curl https://airikr.me/myip?json"
alias run_yt="firefox http://localhost:8080 && cd ~/Downloads/youtube-local/ && pip3 install -r requirements.txt && python3 ~/Downloads/youtube-local/server.py"
alias stop_yt="fuser -k 8080/tcp"
alias smdfb="exiftool -all= /media/$USER/My\ Book/MEGA/Images/Religion/* && exiftool -delete_original /media/$USER/My\ Book/MEGA/Images/Religion/*"' >> ~/.bash_aliases

source ~/.bash_aliases

sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get autoclean -y && sudo apt-get autoremove -y && sudo apt-get clean

sudo apt install -y software-properties-common apt-transport-https wget

wget -O composer-setup.php https://getcomposer.org/installer
wget https://mullvad.net/download/app/deb/latest -O ~/Downloads/mullvad.deb
wget -O - https://deb.beekeeperstudio.io/beekeeper.key | sudo apt-key add -
wget -qO - https://packagecloud.io/AtomEditor/atom/gpgkey | sudo apt-key add -
wget -O - https://raw.githubusercontent.com/laurent22/joplin/dev/Joplin_install_and_update.sh | bash

sudo add-apt-repository -y ppa:git-core/ppa
sudo add-apt-repository -y ppa:papirus/papirus
sudo add-apt-repository -y ppa:agornostal/ulauncher
sudo add-apt-repository -y ppa:atareao/telegram

echo "deb https://deb.beekeeperstudio.io stable main" | sudo tee /etc/apt/sources.list.d/beekeeper-studio-app.list
sudo sh -c 'echo "deb [arch=amd64] https://packagecloud.io/AtomEditor/atom/any/ any main" > /etc/apt/sources.list.d/atom.list'

sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get autoclean -y && sudo apt-get autoremove -y && sudo apt-get clean

if [ $(which flatpak) ]
then
    flatpak install flathub org.gramps_project.Gramps
else
    sudo add-apt-repository ppa:alexlarsson/flatpak
    sudo apt update
    sudo apt install flatpak
    flatpak install flathub org.gramps_project.Gramps
fi

sudo apt install -y papirus-icon-theme openssh-server firefox pwgen digikam ulauncher git qbittorrent filezilla python3-pip libimage-exiftool-perl imagemagick ffmpeg beekeeper-studio atom unzip telegram
sudo dpkg -i ~/Downloads/mullvad.deb

sudo rm ~/Downloads/mullvad.deb

sudo apt install -y apache2 phpmyadmin mysql-server
sudo apt install -y php php-mbstring php-zip php-gd php-json php-curl php-fpm php-bcmath php-imagick php-cli
sudo phpenmod mbstring
sudo phpenmod bcmath
sudo a2enmod rewrite
sudo mysql_secure_installation

echo
echo
echo "1. CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';"
echo "2. GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost';"
echo "3. FLUSH PRIVILEGES;"
echo "4. ALTER USER  'root'@'localhost' IDENTIFIED BY 'password';"
echo "5. FLUSH PRIVILEGES;"
echo "6. quit"
echo
echo

sudo mysql
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
sudo systemctl restart apache2

sudo ufw allow ssh

sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get autoclean -y && sudo apt-get autoremove -y && sudo apt-get clean

echo
echo
echo "Manual installations:"
echo "- SmartGit (https://www.syntevo.com/smartgit/download/)"
echo "- kDrive (https://login.infomaniak.com/en/login)"
echo
echo "Final touch regarding mod_rewrite:"
echo "1. sudo nano /etc/apache2/apache2.conf"
echo "2. Change AllowOverride None to AllowOverride All for <Directory /var/www/>"
echo "3. sudo systemctl restart apache2"
echo
echo "Enabling backdrop-filter in Firefox:"
echo "1. Go to about:config"
echo "2. Set layout.css.backdrop-filter.enabled to true"
echo "3. Set gfx.webrender.all to true"
echo
echo

backtore.sh (backup or restore)

#!/bin/bash

bold=$(tput bold)
normal=$(tput sgr0)
dir="/media/$USER/My Book/linux-backups"
mysql_password="password"

if [ ! -z $1 ] && [ $1 == 'backup' ]
then
        rsync_='rsync -aP --delete'

        [ ! -d "$dir"/home ] && sudo mkdir "$dir"/home/
        [ ! -d "$dir"/home/$USER ] && sudo mkdir "$dir"/home/$USER
        [ ! -d "$dir"/home/$USER/.atom ] && sudo mkdir "$dir"/home/$USER/.atom
        [ ! -d "$dir"/home/$USER/.config ] && sudo mkdir "$dir"/home/$USER/.config
        [ ! -d "$dir"/home/$USER/.gramps ] && sudo mkdir "$dir"/home/$USER/.gramps
        [ ! -d "$dir"/home/$USER/.mozilla ] && sudo mkdir "$dir"/home/$USER/.mozilla
        [ ! -d "$dir"/home/$USER/.mozilla/firefox ] && sudo mkdir "$dir"/home/$USER/.mozilla/firefox

        $rsync_ ~/Documents/FreeFileSync/ "$dir"/home/$USER/Documents/FreeFileSync
        $rsync_ ~/Documents/bash/ "$dir"/home/$USER/Documents/bash
        $rsync_ ~/Downloads/youtube-local/ "$dir"/home/$USER/Downloads/youtube-local
        $rsync_ ~/.atom/ "$dir"/home/$USER/.atom
        $rsync_ ~/.config/ "$dir"/home/$USER/.config
        $rsync_ ~/.gramps/ "$dir"/home/$USER/.gramps
        $rsync_ ~/.mozilla/firefox/ "$dir"/home/$USER/.mozilla/firefox
        $rsync_ /var/www/ "$dir"/var/www

    notify-send Backup "The backup was successful."

elif [ ! -z $1 ] && [ $1 == 'restore' ]
then
        rsync_='rsync -aP'

        sudo chmod -R 777 /var/www

        $rsync_ "$dir"/home/$USER/Documents/bash/ ~/Documents/bash
        $rsync_ "$dir"/home/$USER/Documents/FreeFileSync/ ~/Documents/FreeFileSync
        $rsync_ "$dir"/home/$USER/Downloads/youtube-local/ ~/Downloads/youtube-local
        $rsync_ "$dir"/home/$USER/Pictures/ ~/Pictures
        $rsync_ "$dir"/home/$USER/.atom/ ~/.atom
        $rsync_ "$dir"/home/$USER/.config/ ~/.config
        $rsync_ "$dir"/home/$USER/.gramps/ ~/.gramps
        $rsync_ "$dir"/home/$USER/.mozilla/firefox/ ~/.mozilla/firefox
        $rsync_ "$dir"/var/www/ /var/www

        sudo rm /var/www/html/index.html

        notify-send Restore "The restore was successful."

else
        echo -e "\e[31mYou can only choose ${bold}backup${normal} \e[31mor ${bold}restore${normal} \e[31mas commands."
fi
Page 1 of 1