yay helper to intput sudo password at command entry
With this script, you can run sudo yeo -Syy some-package --noconfirm and sudo yeo -Syyu --noconfirm (et al) instead of needing to babysit for a sudo password in the middle of the usual yay -Syy some-package --noconfirm
Use at your own risk!
Disclaimer: Anything on this page could result in destroying your entire computer or bring the apocalypse or something less or between or far worse! Only use this tool if you know how to use pacman and yay and can install Arch Linux yourself and don't like SysAdmin wages for a CLI babysitting job!
yaywill prompt the SysAdmin or user forsudopasswords in the middle of its execution, meaning the SysAdmin must babysit the terminal duringyayinstalls and updates- This defeats the purpose of using the terminal and scripts, meaning SysAdmin-level hourly cost to watch
yaywork
However, the premise is correct...
- Compiling must not be done by
rootorsudo - A
rootuser compiler can cause many problems, including code not be executable by normal users - But,
yayboth compiles and installs, and installing does requiresudo
How yeo helps...
yeomust be run assudo, then runsyayas a user that does not need a password forsudooperations as they arise
- Run a
sudocommand that takes thesudopassword for the duration of the CLI execution, but runsyaythrough a normal user which has a no-passwordsudopermission - This normal (
worker) user requires asudopassword orrootpermissions to be initiated, but then does not need a password later - The result is that:
- The
sudopassword CLI request moves up to the beginning of the workflow - Where the
sudopassword only needs to be entered once - Thus, we have a "press and walk"
sudocommand more likepacman
- The
sudo
Arch Linux does not come with sudo ready by default
If you have not already enabled sudo, you can enable sudo with this, otherwise skip to 2...
| Turn on sudo: # (must run as root)
groupadd sudo
sed -i "s?# %sudo\tALL=(ALL) ALL?%sudo\tALL=(ALL) ALL?" /etc/sudoersyay
yay must be installed already, if it is then skip 2...
| Install yay AUR helper : $
sudo pacman -Syy --needed base-devel git
cd ~
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si --noconfirm
cd ..
rm -rf yayFirst check for dependencies and any conflict
| Check for yeo tool dependencies & conflicts: $
if which yay && id -u worker; then if which yeo; then echo "yeo may already be installed!"; else echo "Ready to install yeo!"; fi else echo "Cannot install yeo, there is a conflict!"; fiIf you see the message Ready to install yeo! then you are ready to proceed...
| yeo install: $
sudo groupadd worker
sudo useradd -g worker worker
sudo usermod -a -G wheel worker
sudo mkdir -p /opt/vrk/worker
sudo chown -R worker:worker /opt/vrk/worker
sudo usermod -d /opt/vrk/worker worker
sudo usermod -L worker
sudo chsh -s /usr/sbin/bash worker
sudo echo 'worker ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/worker
sudo cat <<'EOF' > /opt/yeo.sh
#!/bin/bash
if [ "$(id -u)" != "0" ]; then
/usr/bin/echo "Must run as root or sudo!"
exit 1
fi
/usr/bin/echo $@ | /usr/bin/grep -q '"'
if [ "$?" != "0" ]; then
/usr/bin/echo $@ | /usr/bin/grep -q "'"
if [ "$?" != "0" ]; then
args="$@"
/usr/bin/sudo -u worker /bin/bash -c "/usr/bin/yay $args"
exit $?
else
/usr/bin/echo "No 'quotes' allowed!"
exit 1
fi
else
/usr/bin/echo "No \"quotes\" allowed!"
exit 1
fi
EOF
sudo chmod 755 /opt/yeo.sh
sudo ln -sfn /opt/yeo.sh /usr/local/bin/yeoNow, you have the option to run sudo yeo where you would normally run yay, including with --noconfirm or such yay options if you like