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 "linux"

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

Starting afresh

_
Cover

I decided to do a fresh re-installation of Linux earlier today and was thinking about switching distribution. I have used Linux Mint Cinnamon since maybe 2018, so I wanted to try something else. I searched for the best light-weighted Linux distributions out there and found a distribution that I tried many years ago: Xubuntu.

My journey to a different Linux distribution turned out to be quite bumpy. After making my flash drive bootable with Xubuntu 20.04 LTS, I restarted the desktop and ran the installation. It went smoothly and when I finally got into the desktop environment, I headed to my own wiki page.

After copying the content of install.sh and pasted it in a new file with the same filename via the terminal, I run it and waited for it to be done.It turned out that it skipped a lot since none of the softwares I included got installed + some other things. I went through everything again, step-by-step, and that worked.

I opened Software & Drivers to see what graphic drivers I had to choose from. But to my surpise, all the options were disabled besides of the last one (the active one). I didn't think that much about it at the time.

I finished the installations and configurations and restarted the computer. When I came back to the desktop environment, the resolution was set to 640x480. "What in the world...", I thought to myself, and opened Display from settings. 640x480 was the only option! Restarted the computer again, nothing changed. Searched for a solution, found sudo apt install nvidia-460 so I ran that command and restarted the computer.

The issue persisted so I gave up and was going to restart the computer in order to boot to Windows 10. But, I couldn't. Nothing happened when I clicked on the whisker menu and no keyboard shortcuts worked. What the actual fuck?! I did the forbidden: a hard shutdown. I'm sorry, computer.

The end of the nightmare... sort of

After downloading the same ISO file but in Windows this time, and made the flash drive bootable again via Rufus, I restarted the computer and let it boot from the flash drive. The installation looked different. Fewer options compared to before.

After the installation, I went to my wiki page again and copied and pasted the content in install.sh, and ran the bash script. Huh. It actually installed everything this time. I went to Software & Drivers again and waited for the additional drivers to load. I was able to choose desire drivers! Woho!

Restarted the computer and hoped for the best. Everything loaded just fine. Yay! But! I can't change the top bar of every window, even if I choose a different theme (also downloaded ones). The top bar didn't change its appearance, more than making it light or dark depending on what theme I chose.

A screenshot showing the top bar in a window of a software in Linux.

Super annoying!

(You can open the screenshot into a new tab by right-clicking or long-pressing it and choose "Open image in New Tab".)

But that's not all! Having autism, I can annoy me even for a small thing like having Firefox and Atom in the wrong order in the taskbar when they are open. And I can't do shit about it, even if I first open Firefox and then Atom! Atom always come before Firefox! Gah!!

Switched back to Linux Mint Cinnamon

I liked Xubuntu at first, but after a while, I didn't liked it at all. I got tired of the issues and the thought about being forced to configure more than I had to. For an example, I didn't like the file manager (Thunar). So I ended up installing Linux Mint Cinnamon again.

Have now "perfected" the system to my liking and also improved my install.sh script. I also created a backup.sh which will backup my configurations and databases once in a while through crontab. The backup script will backup my files to Backblaze B2 CLoud Storage.

Page 1 of 1