我正在尝试运行命令:
root@minimanode:/# sudo wget -O minima_setup.sh https://raw.githubusercontent.com/minima-global/Minima/master/scripts/minima_setup.sh && chmod +x minima_setup.sh && sudo ./minima_setup.sh -r 9002 -p 9001
并输出:useradd: group '9001' does not exist
该怎么办?
Ubuntu 20.04.3 LTS(GNU/Linux 5.4.0-104-通用 x86_64)
答案1
这是因为正如它所说,它没有找到任何具有该 gid 的组,为什么不在运行安装脚本之前创建该组,然后删除其上的创建行呢?
userdel minima | groupdel minima
然后groupadd -g 9001 minima
如果你之前运行过这个,那么 if 块将是不必要的,getent
从组中读取信息(所以我删除了它)
脚本:
#!/bin/sh
set -e
CLEAN_FLAG=''
PORT=''
HOST=''
HOME="/home/minima"
CONNECTION_HOST=''
CONNECTION_PORT=''
SLEEP=''
RPC=''
print_usage() {
printf "Usage: Setups a new minima service for the specified port"
}
while getopts ':xsc::p:r:d:h:' flag; do
case "${flag}" in
s) SLEEP='true';;
x) CLEAN_FLAG='true';;
r) RPC="${OPTARG}";;
c) CONNECTION_HOST=$(echo $OPTARG | cut -f1 -d:);
CONNECTION_PORT=$(echo $OPTARG | cut -f2 -d:);;
p) PORT="${OPTARG}";;
d) HOME="${OPTARG}";;
h) HOST="${OPTARG}";;
*) print_usage
exit 1 ;;
esac
done
apt update
apt install openjdk-11-jre-headless curl jq -y
if ! id -u 9001 > /dev/null 2>&1; then
echo "[+] Adding minima user"
useradd -r -u 9001 -g 9001 -d $HOME minima
mkdir $HOME
chown minima:minima $HOME
fi
wget -q -O $HOME"/minima_service.sh" "https://github.com/minima-global/Minima/raw/master/scripts/minima_service.sh"
chown minima:minima $HOME"/minima_service.sh"
chmod +x $HOME"/minima_service.sh"
CMD="$HOME/minima_service.sh -s $@"
CRONSTRING="#!/bin/sh
$CMD"
echo "$CRONSTRING" > /etc/cron.weekly/minima_$PORT
chmod a+x /etc/cron.weekly/minima_$PORT
CMD="$HOME/minima_service.sh $@"
/bin/sh -c "$CMD"
echo "Install complete - showing logs now - Ctrl-C to exit logs, minima will keep running"
journalctl -fn 10 -u minima_$PORT
PS:作为建议,请下次提供更多信息、代码或类似的东西,我必须在互联网上搜索我正在编辑的内容。