简体   繁体   English

Arch Linux:创建另一个用户时 makepkg 出错

[英]Arch Linux: Error in makepkg w/ creating another user

Like the title suggests, I'm using Arch Linuxx on a virtualbox with just xfce4 installed I want to create a script that installs yay.正如标题所暗示的那样,我在仅安装了 xfce4 的虚拟机上使用 Arch Linuxx 我想创建一个安装 yay 的脚本。 I know that the makepkg command cannot be run on root so I decided to create a script.我知道 makepkg 命令不能在 root 上运行,所以我决定创建一个脚本。

# Setting up AUR and installing yay in this machine
cd /home
mkdir data
cd /home/data
sudo useradd -p $(openssl passwd -1 liveuser) liveuser
su liveuser
git clone https://aur.archlinux.org/yay.git
chmod 777 yay
cd yay./
makepkg -si
exit
userdel -r liveuser

But the result I get is this:但我得到的结果是这样的:

[root@archevaris Desktop]# ./APPINSTALLER.sh
[liveuser@archevaris EVARIS]$ 

It does not execute the rest of the code properly.它没有正确执行其余的代码。 I don't see any changes in the /home/data folder.我在 /home/data 文件夹中没有看到任何更改。 Is there anything wrong with the script I made??我写的脚本有问题吗?? The script above is based on the forum I made: [ https://linux.org/threads/yay-not-installing-in-arch-linux.27414/#post-84056][1]上面的脚本基于我制作的论坛:[ https://linux.org/threads/yay-not-installing-in-arch-linux.27414/#post-84056][1]

Any issues with the script?脚本有问题吗?

Voilà.瞧。 I commented it accurately so you can see.我准确地评论了它,所以你可以看到。

#!/bin/bash
##################################################################################################################
# This section here is just to understand where the script is and then come back here at the end of the execution.
SOURCE="${BASH_SOURCE[0]}"
# Following cycle to resolve $SOURCE until the file is no longer a symlink
while [ -h "$SOURCE" ]; do 
  DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
  SOURCE="$(readlink "$SOURCE")"
# If $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
  [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" 
done
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
##################################################################################################################
# Want to go back to the symlink if that is supposed behaviour? Then delete until here and uncomment next line
#DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
##################################################################################################################
#
# HERE IS WHERE YOUR ACTUAL SCRIPT BEGINS:
#
# Defining variables:
TEMPACCOUNT="liveuser"
DESTINATION="/home/$TEMPACCOUNT"
# Adding your temp user and giving it a home folder where it can downloads the source code
useradd -m -p $(openssl passwd -1 $TEMPACCOUNT) $TEMPACCOUNT
# He has to launch the command as non-root user, but he'll need to give admin permission at the end. Adding to sudoers.
echo "$TEMPACCOUNT ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
# Next line is to install packages needed to install yay. I may have forgotten some. I leave the line commented.
#pacman -S git make fakeroot go binutils --noconfirm
# Move to his home folder
cd $DESTINATION
# Create the script in his home folder
echo '#!/bin/bash' > $DESTINATION/yay-setup.sh
echo -e "git clone https://aur.archlinux.org/yay-bin.git\ncd $DESTINATION/yay-bin\nmakepkg --noconfirm -si" >> $DESTINATION/yay-setup.sh
chmod +x $DESTINATION/yay-setup.sh
# Done, now pass the following commands to the SU session we're about to open. << is crucial here, That's what you missed
su $TEMPACCOUNT<<'EOF'
set -e
/bin/bash "yay-setup.sh"
exit
EOF
# Remove the temp user from sudoers file by deleting last line
sed '$d' /etc/sudoers > /etc/sudoers
# The following line is actually pretty useless, userdel -r will wipe this anyway
rm -R yay-*
# And we go back to home sweet home
cd $DIR
# And we delete the temp user
userdel -r $TEMPACCOUNT

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM