melawy-skel-root/root/.local/bin/key-sign.sh

155 lines
4.5 KiB
Bash
Raw Normal View History

2023-11-22 11:29:04 +05:00
#!/bin/bash
2024-12-02 11:52:16 +05:00
2024-12-17 00:06:47 +05:00
key_status1=$(env LANG=C pacman-key -f valeria@fadeeva.me 2>&1 | grep "unknown")
key_status2=$(env LANG=C pacman-key -f erik.dubois@gmail.com 2>&1 | grep "unknown")
if [[ -z $key_status1 ]] && [[ -z $key_status2 ]]; then
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}"
2025-01-06 15:27:16 +05:00
if [ ! -x "$0" ]; then
2024-12-17 00:06:47 +05:00
chmod +x "$0"
fi
sudo /bin/sh -c "$0"
exit
fi
done
if [[ $counter -eq 0 ]]; then
2024-12-02 11:52:16 +05:00
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 ""
echo -e "Add the user '${USER}' to the wheel group - COPY AND PASTE in new konsole:\n
2024-12-17 00:06:47 +05:00
su -c \"usermod -a -G wheel ${USER}\"; qdbus org.kde.LogoutPrompt /LogoutPrompt promptLogout; exit"
2024-12-02 11:52:16 +05:00
echo ""
echo "Or otherwise escalate privileges and run the program \"${HOME}/.config/autostart/$(basename ${0}).desktop\" again."
echo ""
echo -e "Help: https://wiki.archlinux.org/title/Sudo \nhttps://wiki.archlinux.org/title/Users_and_groups"
echo ""
echo "The program path is the ${HOME}/.local/bin/$(basename ${0})"
echo "The shortcut path is the ${HOME}/.config/autostart/$(basename ${0}).desktop"
echo ""
echo "Waiting new konsole windows..."
sleep 5
/usr/bin/konsole
exit
fi
2024-12-17 00:06:47 +05:00
fi
2024-12-02 11:52:16 +05:00
2024-12-17 00:06:47 +05:00
# if [[ "$UID" != 0 ]]; then
# echo "USER NOT ROOT"
# sudo "$0"
# exit
# else
# echo "USER IS ROOT"
# fi
grep_text=$(ss -nlp | grep 9050)
if [[ "$?" == 0 ]]; then
export http_proxy="socks5://127.0.0.1:9050"
export https_proxy="socks5://127.0.0.1:9050"
export ftp_proxy="socks5://127.0.0.1:9050"
2023-11-22 11:29:04 +05:00
fi
2023-11-29 03:04:55 +05:00
ping -c 1 1.1.1.1 > /dev/null
have_internet="$?"
2023-11-23 15:37:02 +05:00
# sleep 1
2023-11-23 01:03:12 +05:00
2023-11-22 11:29:04 +05:00
cd "/root"
2024-12-02 11:52:16 +05:00
rm -rf /var/lib/pacman/sync/*
2024-05-22 23:59:35 +05:00
rm -rf /etc/pacman.d/gnupg/*
2023-11-23 01:53:21 +05:00
mkdir -p /root/.gnupg 2>/dev/null
2023-11-22 22:01:29 +05:00
chmod 700 /root/.gnupg
2023-11-22 11:29:04 +05:00
haveged -w 1024
pacman-key --init
pkill haveged
2023-12-19 02:32:26 +05:00
pacman-key --add /usr/share/pacman/keyrings/melawy-linux.gpg
pacman-key --lsign-key BC8B600E8DDA1F4CB77B10D2BA803A261A5EE6B8
pacman-key --lsign-key B175815513971572FE7B1557CEC07AC8FF64DA4B
2024-12-17 00:06:47 +05:00
# if [ "$have_internet" -eq 0 ]; then
# pacman-key --keyserver hkps://keys.openpgp.org --recv-keys BC8B600E8DDA1F4CB77B10D2BA803A261A5EE6B8
# pacman-key --keyserver hkps://keyserver.ubuntu.com --recv-keys BC8B600E8DDA1F4CB77B10D2BA803A261A5EE6B8
# pacman-key --lsign-key BC8B600E8DDA1F4CB77B10D2BA803A261A5EE6B8
#
# pacman-key --keyserver hkps://keys.openpgp.org --recv-keys B175815513971572FE7B1557CEC07AC8FF64DA4B
# pacman-key --keyserver hkps://keyserver.ubuntu.com --recv-keys B175815513971572FE7B1557CEC07AC8FF64DA4B
# pacman-key --lsign-key B175815513971572FE7B1557CEC07AC8FF64DA4B
# fi
2023-11-22 11:29:04 +05:00
pacman-key --lsign-key melawy-linux
2024-01-08 13:25:12 +05:00
2024-01-28 01:01:28 +05:00
pacman-key --add /usr/share/pacman/keyrings/manjaro.gpg
pacman-key --lsign-key manjaro
2024-01-08 13:25:12 +05:00
pacman-key --add /usr/share/pacman/keyrings/cachyos.gpg
2023-11-29 03:04:55 +05:00
pacman-key --lsign-key cachyos
2024-01-08 13:25:12 +05:00
pacman-key --add /usr/share/pacman/keyrings/arcolinux.gpg
2023-11-22 11:29:04 +05:00
pacman-key --lsign-key arcolinux
2024-01-08 13:25:12 +05:00
pacman-key --add /usr/share/pacman/keyrings/chaotic.gpg
2023-11-22 11:29:04 +05:00
pacman-key --lsign-key chaotic
2024-01-08 13:25:12 +05:00
pacman-key --add /usr/share/pacman/keyrings/endeavouros.gpg
2023-11-29 03:04:55 +05:00
pacman-key --lsign-key endeavouros
2023-11-22 11:29:04 +05:00
2023-12-19 02:32:26 +05:00
pacman-key --populate
2023-11-22 11:29:04 +05:00
2024-05-22 23:59:35 +05:00
echo "
keyserver hkp://keyserver.ubuntu.com:80" | sudo tee --append /etc/pacman.d/gnupg/gpg.conf
2023-11-22 11:29:04 +05:00
pacman-key --updatedb
2024-12-17 00:06:47 +05:00
# if [ "$have_internet" -eq 0 ]; then
# pacman -Sy
# fi
2023-11-23 01:53:21 +05:00
title="Successed!"
msg="$(date '+%Y.%m.%d %H:%M:%S')"
users=$(/usr/bin/users | sed 's| |\n|g' | sort | uniq)
for user in $users
do
userid=$(/usr/bin/id -u "$user")
2024-12-17 00:06:47 +05:00
if [ -S "/run/user/$userid/bus" ]; then
cmd=(
DISPLAY=:0
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/"$userid"/bus
/usr/bin/notify-send
--icon=info
--urgency=low
-t 5000
-a "'Keys sign'"
"'$title'"
"'$msg'"
)
/usr/bin/su "$user" -c "${cmd[*]}"
if [ "$user" != "root" ] && [ "$user" != "liveuser" ]; then
if [ -f "/home/$user/.config/autostart/key-sign.sh.desktop" ]; then
rm /home/"$user"/.config/autostart/key-sign.sh.desktop
# rm /home/"$user"/.local/bin/key-sign.sh
fi
fi
fi
2023-11-23 01:53:21 +05:00
done
2024-12-02 11:52:16 +05:00
2024-12-17 00:06:47 +05:00
echo "Finish!!!"
2024-12-02 11:52:16 +05:00
sleep 5