deep-wine-runner/Mount.sh

42 lines
1014 B
Bash
Raw Normal View History

#!/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-02 19:16:08 +08:00
echo $0
echo $1
echo $2
echo $3
# 挂载必备目录
cd "$1"
mount --bind /dev ./dev
2022-12-02 22:26:10 +08:00
#mount --bind /dev/pts ./dev/pts
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-02 19:16:08 +08:00
chmod 777 -R root
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以便读写
chroot . echo -e "123456\n123456\n\n\n\n\n\n\n\n\n" | adduser "$2"
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
# 如果参数 3 存在
2022-12-02 22:26:10 +08:00
chroot "--userspec=$2:$2" . env "HOME=/home/$2" "${@:3}"