-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathMount.sh
executable file
·58 lines (58 loc) · 1.59 KB
/
Mount.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
if [ ` whoami ` != "root" ]; then
echo "Only root can run me"
exit 1
fi
if [ ! -d "$1" ]; then
echo "路径不存在!"
exit 1
fi
programPath=`dirname $0`
echo $0
echo $1
echo $2
echo $3
# 挂载必备目录
cd "$1"
# 拷贝 Qemu Static
cp -r /usr/bin/qemu-*-static ./usr/bin
# 挂载目录
# 此部分将会由 pardus-chroot 来处理
#mount --bind /dev ./dev
#mount --bind /dev/pts ./dev/pts
#mount -t proc /proc ./proc
#mount --bind /etc/resolv.conf ./etc/resolv.conf
#mount -t sysfs /sys ./sys
#mount --bind /dev/shm ./dev/shm
chmod 777 -R root tmp
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,以便读写
"$programPath/pardus-chroot" . bash /opt/apps/deepin-wine-runner/ChangePassword.sh "$2"
mkdir -p "home/$2"
chmod 777 -Rv "home/$2"
fi
# 挂载用户目录到 /root(默认 $HOME 路径)
if [[ $2 == "root" ]]; then
mount --bind root "$1/root/"
else
mount --bind "/home/$2" "$1/home/$2"
fi
# 挂载此内容以可以跨架构运行程序
mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
systemctl restart binfmt-support.service
# 判断是否有 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
# 如果参数 3 存在
"$programPath/pardus-chroot" . #env "HOME=/home/$2" ${@:3}
chroot "--userspec=$2:$2" . env "HOME=/home/$2" ${@:3}