2022-11-30 14:37:37 +08:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
if [ ` whoami ` != "root" ]; then
|
|
|
|
|
echo "Only root can run me"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
if [ ! -d "$1" ]; then
|
|
|
|
|
echo "路径不存在!"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
2022-12-25 22:28:46 +08:00
|
|
|
|
programPath=`dirname $0`
|
2022-12-02 19:16:08 +08:00
|
|
|
|
echo $0
|
|
|
|
|
echo $1
|
|
|
|
|
echo $2
|
|
|
|
|
echo $3
|
2022-11-30 14:37:37 +08:00
|
|
|
|
# 挂载必备目录
|
|
|
|
|
cd "$1"
|
2022-12-06 12:44:53 +08:00
|
|
|
|
# 拷贝 Qemu Static
|
|
|
|
|
cp -r /usr/bin/qemu-*-static ./usr/bin
|
|
|
|
|
# 挂载目录
|
2022-12-25 22:28:46 +08:00
|
|
|
|
# 此部分将会由 pardus-chroot 来处理
|
|
|
|
|
#mount --bind /dev ./dev
|
2022-12-02 22:26:10 +08:00
|
|
|
|
#mount --bind /dev/pts ./dev/pts
|
2022-12-25 22:28:46 +08:00
|
|
|
|
#mount -t proc /proc ./proc
|
|
|
|
|
#mount --bind /etc/resolv.conf ./etc/resolv.conf
|
|
|
|
|
#mount -t sysfs /sys ./sys
|
2022-12-02 22:26:10 +08:00
|
|
|
|
#mount --bind /dev/shm ./dev/shm
|
2022-12-25 22:28:46 +08:00
|
|
|
|
chmod 777 -R root tmp
|
2022-12-02 19:16:08 +08:00
|
|
|
|
xhost +
|
|
|
|
|
# 挂载 Wine 运行器目录
|
|
|
|
|
mount -o bind `dirname $0` ./opt/apps/deepin-wine-runner/
|
|
|
|
|
# 挂载字体
|
|
|
|
|
mount -o bind /usr/share/fonts ./usr/share/fonts
|
|
|
|
|
# 配置用户
|
|
|
|
|
if [ ! -d "home/$2" ]; then
|
|
|
|
|
# 新建用户,且密码为 123456,以便读写
|
2022-12-25 22:28:46 +08:00
|
|
|
|
"$programPath/pardus-chroot" . bash /opt/apps/deepin-wine-runner/ChangePassword.sh "$2"
|
2022-12-02 19:16:08 +08:00
|
|
|
|
fi
|
|
|
|
|
# 挂载用户目录到 /root(默认 $HOME 路径)
|
|
|
|
|
if [[ $2 == "root" ]]; then
|
|
|
|
|
mount --bind root "$1/root/"
|
|
|
|
|
else
|
2022-12-02 22:26:10 +08:00
|
|
|
|
mount --bind "/home/$2" "$1/home/$2"
|
2022-12-02 19:16:08 +08:00
|
|
|
|
fi
|
2023-01-22 09:48:35 +08:00
|
|
|
|
# 挂载此内容以可以跨架构运行程序
|
|
|
|
|
mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
|
2023-02-26 21:43:41 +08:00
|
|
|
|
# 判断是否有 Root 权限
|
|
|
|
|
cat etc/sudoers | grep "$2"
|
|
|
|
|
if [[ $? != 0 ]]; then
|
|
|
|
|
echo "$2 ALL=(ALL:ALL) ALL" >> etc/sudoers
|
|
|
|
|
fi
|
|
|
|
|
# 写入 DNS
|
|
|
|
|
cat /etc/resolv.conf > etc/resolv.conf
|
2022-12-02 19:16:08 +08:00
|
|
|
|
# 如果参数 3 存在
|
2023-03-03 22:25:33 +08:00
|
|
|
|
"$programPath/pardus-chroot" --userspec=$2:$2 . env "HOME=/home/$2" ${@:3}
|