Replace sudo with doas

Original message: https://t.me/TelegramDesktopTalk/96918
This commit is contained in:
Michael De Roover 2023-03-01 01:37:00 +01:00
parent ff62441bc8
commit ab07f0f635
Signed by: vim
GPG Key ID: 075496E232CE04CB
1 changed files with 6 additions and 6 deletions

View File

@ -1,6 +1,5 @@
#!/bin/sh
# Check whether script is executed by root
f_perm_err(){
printf "This script has been executed as the root user.\n"
printf "Please run it as a regular user instead.\n"
@ -10,7 +9,7 @@ f_perm_err(){
f_mount_storage(){
printf "Mounting $1 storage...\n"
[ ! -d $2 ] && mkdir $2
sudo mount -t tmpfs -o size=256M,mode=1777 tg-$1 $2
doas mount -t tmpfs -o size=256M,mode=1777 tg-$1 $2
}
f_remove_cache(){
@ -30,18 +29,19 @@ f_copy_data(){
f_rsync_data(){
printf "Copying data from $1 to $2 storage...\n"
rsync -a --delete $3/ $4
doas rsync -a --delete $3/ $4
}
f_umount_storage(){
printf "Removing $1 storage...\n"
sudo umount tg-$1
doas umount tg-$1
[ ! -z $2 ] && \
printf "Deleting directory...\n" && \
rm -r $2
}
[ $(id -u) == "0" ] && f_perm_err
# Check whether script is executed by root
[ "$(id -u)" -eq "0" ] && f_perm_err
# Environment variables
tmp="/tmp/tg-temporary"
@ -60,7 +60,7 @@ f_umount_storage transitory $tmp
# Launch Telegram application
printf "Launching Telegram...\n"
telegram 2>/dev/null
telegram-desktop #2>/dev/null
# Tear down the tmpfs for Telegram
f_remove_cache temporary $data