Replace sudo with doas
Original message: https://t.me/TelegramDesktopTalk/96918
This commit is contained in:
parent
ff62441bc8
commit
ab07f0f635
12
tg-setup
12
tg-setup
@ -1,6 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# Check whether script is executed by root
|
|
||||||
f_perm_err(){
|
f_perm_err(){
|
||||||
printf "This script has been executed as the root user.\n"
|
printf "This script has been executed as the root user.\n"
|
||||||
printf "Please run it as a regular user instead.\n"
|
printf "Please run it as a regular user instead.\n"
|
||||||
@ -10,7 +9,7 @@ f_perm_err(){
|
|||||||
f_mount_storage(){
|
f_mount_storage(){
|
||||||
printf "Mounting $1 storage...\n"
|
printf "Mounting $1 storage...\n"
|
||||||
[ ! -d $2 ] && mkdir $2
|
[ ! -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(){
|
f_remove_cache(){
|
||||||
@ -30,18 +29,19 @@ f_copy_data(){
|
|||||||
|
|
||||||
f_rsync_data(){
|
f_rsync_data(){
|
||||||
printf "Copying data from $1 to $2 storage...\n"
|
printf "Copying data from $1 to $2 storage...\n"
|
||||||
rsync -a --delete $3/ $4
|
doas rsync -a --delete $3/ $4
|
||||||
}
|
}
|
||||||
|
|
||||||
f_umount_storage(){
|
f_umount_storage(){
|
||||||
printf "Removing $1 storage...\n"
|
printf "Removing $1 storage...\n"
|
||||||
sudo umount tg-$1
|
doas umount tg-$1
|
||||||
[ ! -z $2 ] && \
|
[ ! -z $2 ] && \
|
||||||
printf "Deleting directory...\n" && \
|
printf "Deleting directory...\n" && \
|
||||||
rm -r $2
|
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
|
# Environment variables
|
||||||
tmp="/tmp/tg-temporary"
|
tmp="/tmp/tg-temporary"
|
||||||
@ -60,7 +60,7 @@ f_umount_storage transitory $tmp
|
|||||||
|
|
||||||
# Launch Telegram application
|
# Launch Telegram application
|
||||||
printf "Launching Telegram...\n"
|
printf "Launching Telegram...\n"
|
||||||
telegram 2>/dev/null
|
telegram-desktop #2>/dev/null
|
||||||
|
|
||||||
# Tear down the tmpfs for Telegram
|
# Tear down the tmpfs for Telegram
|
||||||
f_remove_cache temporary $data
|
f_remove_cache temporary $data
|
||||||
|
Loading…
x
Reference in New Issue
Block a user