diff --git a/tg-setup b/tg-setup index d1d4f92..f466602 100644 --- a/tg-setup +++ b/tg-setup @@ -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