tg-setup/tg-setup

32 lines
664 B
Bash

#!/bin/sh
permerr(){
printf "This script has been executed as the root user.\n"
printf "Please run it as a regular user instead.\n"
exit 1
}
[ $(id -u) == "0" ] && permerr
# Environment variables
user_id=$(id -u)
user_name=$(whoami)
tmp="/tmp/tg-setup"
data="/home/${user_name}/.local/share/TelegramDesktop"
# Establish the tmpfs for Telegram
mkdir $tmp
cp -rv $data/* $tmp
sudo mount -t tmpfs -o size=256M,mode=1777 telegram $data
cp -rv $tmp/* $data/
telegram
read -p "Do you want to remove the cached application data? (y/n) " remove_app_data
f_remove_app_data(){
sudo umount telegram
rm -r $tmp
}
[ "$remove_app_data" != "n" ] && f_remove_app_data