This commit is contained in:
Valeria Fadeeva 2024-12-17 00:06:47 +05:00
parent 6ffe7e28e0
commit 1540e0caa5
1 changed files with 72 additions and 44 deletions

View File

@ -1,17 +1,36 @@
#!/bin/bash #!/bin/bash
for group in $(groups) key_status1=$(env LANG=C pacman-key -f valeria@fadeeva.me 2>&1 | grep "unknown")
do
if [ "${group}" == "wheel" ] || [ "${group}" == "root" ]; then key_status2=$(env LANG=C pacman-key -f erik.dubois@gmail.com 2>&1 | grep "unknown")
echo "The user ${USER} is a member of the group ${group}"
break if [[ -z $key_status1 ]] && [[ -z $key_status2 ]]; then
else exit
fi
if [[ "$UID" != 0 ]]; then
counter=0
for group in $(groups)
do
if [ "${group}" == "wheel" ] || [ "${group}" == "root" ]; then
counter=$(( counter + 1 ))
echo "The user '${USER}' is a member of the group ${group}"
if [ ! -x "$0" ];
chmod +x "$0"
fi
sudo /bin/sh -c "$0"
exit
fi
done
if [[ $counter -eq 0 ]]; then
echo "The user '${USER}' does not have permission to run this program." echo "The user '${USER}' does not have permission to run this program."
echo "The user '${USER}' is not a member of the wheel or root group." echo "The user '${USER}' is not a member of the wheel or root group."
echo "" echo ""
echo -e "Add the user '${USER}' to the wheel group - COPY AND PASTE in new konsole:\n echo -e "Add the user '${USER}' to the wheel group - COPY AND PASTE in new konsole:\n
su -c \"usermod -a -G wheel ${USER}\"; qdbus org.kde.LogoutPrompt /LogoutPrompt promptLogout; exit" su -c \"usermod -a -G wheel ${USER}\"; qdbus org.kde.LogoutPrompt /LogoutPrompt promptLogout; exit"
echo "" echo ""
echo "Or otherwise escalate privileges and run the program \"${HOME}/.config/autostart/$(basename ${0}).desktop\" again." echo "Or otherwise escalate privileges and run the program \"${HOME}/.config/autostart/$(basename ${0}).desktop\" again."
echo "" echo ""
@ -27,15 +46,21 @@ do
/usr/bin/konsole /usr/bin/konsole
exit exit
fi fi
done fi
# if [[ "$UID" != 0 ]]; then
# echo "USER NOT ROOT"
# sudo "$0"
# exit
# else
# echo "USER IS ROOT"
# fi
if [[ "$UID" != 0 ]]; then grep_text=$(ss -nlp | grep 9050)
echo "USER NOT ROOT" if [[ "$?" == 0 ]]; then
sudo "$0" export http_proxy="socks5://127.0.0.1:9050"
exit export https_proxy="socks5://127.0.0.1:9050"
else export ftp_proxy="socks5://127.0.0.1:9050"
echo "USER IS ROOT"
fi fi
ping -c 1 1.1.1.1 > /dev/null ping -c 1 1.1.1.1 > /dev/null
@ -59,15 +84,15 @@ pacman-key --add /usr/share/pacman/keyrings/melawy-linux.gpg
pacman-key --lsign-key BC8B600E8DDA1F4CB77B10D2BA803A261A5EE6B8 pacman-key --lsign-key BC8B600E8DDA1F4CB77B10D2BA803A261A5EE6B8
pacman-key --lsign-key B175815513971572FE7B1557CEC07AC8FF64DA4B pacman-key --lsign-key B175815513971572FE7B1557CEC07AC8FF64DA4B
if [ "$have_internet" -eq 0 ]; then # if [ "$have_internet" -eq 0 ]; then
pacman-key --keyserver hkps://keys.openpgp.org --recv-keys BC8B600E8DDA1F4CB77B10D2BA803A261A5EE6B8 # pacman-key --keyserver hkps://keys.openpgp.org --recv-keys BC8B600E8DDA1F4CB77B10D2BA803A261A5EE6B8
pacman-key --keyserver hkps://keyserver.ubuntu.com --recv-keys BC8B600E8DDA1F4CB77B10D2BA803A261A5EE6B8 # pacman-key --keyserver hkps://keyserver.ubuntu.com --recv-keys BC8B600E8DDA1F4CB77B10D2BA803A261A5EE6B8
pacman-key --lsign-key BC8B600E8DDA1F4CB77B10D2BA803A261A5EE6B8 # pacman-key --lsign-key BC8B600E8DDA1F4CB77B10D2BA803A261A5EE6B8
#
pacman-key --keyserver hkps://keys.openpgp.org --recv-keys B175815513971572FE7B1557CEC07AC8FF64DA4B # pacman-key --keyserver hkps://keys.openpgp.org --recv-keys B175815513971572FE7B1557CEC07AC8FF64DA4B
pacman-key --keyserver hkps://keyserver.ubuntu.com --recv-keys B175815513971572FE7B1557CEC07AC8FF64DA4B # pacman-key --keyserver hkps://keyserver.ubuntu.com --recv-keys B175815513971572FE7B1557CEC07AC8FF64DA4B
pacman-key --lsign-key B175815513971572FE7B1557CEC07AC8FF64DA4B # pacman-key --lsign-key B175815513971572FE7B1557CEC07AC8FF64DA4B
fi # fi
pacman-key --lsign-key melawy-linux pacman-key --lsign-key melawy-linux
@ -89,9 +114,9 @@ keyserver hkp://keyserver.ubuntu.com:80" | sudo tee --append /etc/pacman.d/gnupg
pacman-key --updatedb pacman-key --updatedb
if [ "$have_internet" -eq 0 ]; then # if [ "$have_internet" -eq 0 ]; then
pacman -Sy # pacman -Sy
fi # fi
title="Successed!" title="Successed!"
msg="$(date '+%Y.%m.%d %H:%M:%S')" msg="$(date '+%Y.%m.%d %H:%M:%S')"
@ -101,26 +126,29 @@ for user in $users
do do
userid=$(/usr/bin/id -u "$user") userid=$(/usr/bin/id -u "$user")
cmd=( if [ -S "/run/user/$userid/bus" ]; then
DISPLAY=:0 cmd=(
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/"$userid"/bus DISPLAY=:0
/usr/bin/notify-send DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/"$userid"/bus
--icon=info /usr/bin/notify-send
--urgency=low --icon=info
-t 5000 --urgency=low
-a "'Keys sign'" -t 5000
"'$title'" -a "'Keys sign'"
"'$msg'" "'$title'"
) "'$msg'"
)
/usr/bin/su "$user" -c "${cmd[*]}" /usr/bin/su "$user" -c "${cmd[*]}"
if [ "$user" != "liveuser" ]; then if [ "$user" != "root" ] && [ "$user" != "liveuser" ]; then
rm /home/"$user"/.config/autostart/key-sign.sh.desktop if [ -f "/home/$user/.config/autostart/key-sign.sh.desktop" ]; then
# rm /home/"$user"/.local/bin/key-sign.sh rm /home/"$user"/.config/autostart/key-sign.sh.desktop
fi # rm /home/"$user"/.local/bin/key-sign.sh
fi
fi
fi
done done
echo "This window will close in 5 seconds" echo "Finish!!!"
sleep 5 sleep 5