blob: 6d30586d1c5ba9154b6a4aa8cf6ffd80ddd6bc89 (
plain)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
post_install() {
LINGLONG_ROOT="/var/lib/linglong"
VERSION=0
if [ -f /etc/os-release ]; then
VERSION=$(sed -ne '/^VERSION_ID=.*$/P' /etc/os-release | awk -F = '{print $2}' | sed -e 's/"//g' | awk -F . '{print $1}')
if [ -z "${VERSION}" ]; then
VERSION=0
fi
if [ ${VERSION} -eq 20 ]; then
LINGLONG_ROOT="/data/linglong"
elif [ ${VERSION} -eq 23 ]; then
LINGLONG_ROOT="/persistent/linglong"
fi
fi
if [ ! -d ${LINGLONG_ROOT}/repo ]; then
mkdir -p ${LINGLONG_ROOT}/layers
ostree --repo=${LINGLONG_ROOT}/repo init --mode=bare-user-only
ostree --repo=${LINGLONG_ROOT}/repo config set --group core min-free-space-size 600MB
ostree --repo=${LINGLONG_ROOT}/repo remote add --no-gpg-verify repo https://mirror-repo-linglong.deepin.com/repos/repo
chmod -R 0775 ${LINGLONG_ROOT}
else
echo "Directory is already exists."
fi
#copy config.json to LINGLONG_ROOT
if [ ! -f ${LINGLONG_ROOT}/config.json ]; then
cp /usr/share/linglong/config.json ${LINGLONG_ROOT}/config.json
fi
#daemon-reload for /usr/lib/systemd/user-environment-generators/61-linglong
if [ -f /usr/lib/systemd/user-environment-generators/61-linglong ]; then
systemctl daemon-reload
fi
useruid=400
usergid=400
if [ $(grep -cw "deepin-linglong" /etc/passwd) -gt '0' ]; then
deepinlinglonguid=$(id deepin-linglong | awk -F= '{print $2}' | awk -F"(" '{print $1}')
if [ $deepinlinglonguid -ge 400 ] && [ $deepinlinglonguid -le 499 ]; then
useruid=$deepinlinglonguid
else
while [ $(getent passwd $useruid | wc -l) -gt 0 ]; do
useruid=$(expr $useruid + 1)
if [ $useruid -ge 499 ]; then
echo "uid400-499被占用"
fi
done
fi
deepinlinglonggid=$(id deepin-linglong | awk -F= '{print $3}' | awk -F"(" '{print $1}')
if [ $deepinlinglonggid -ge 400 ] && [ $deepinlinglonggid -le 499 ]; then
usergid=$deepinlinglonggid
else
while [ $(getent passwd $usergid | wc -l) -gt 0 ]; do
usergid=$(expr $usergid + 1)
if [ $usergid -ge 499 ]; then
echo "gid400-499被占用"
fi
done
fi
groupmod -g $usergid deepin-linglong
usermod -u $useruid -s /sbin/nologin deepin-linglong
if ! $(groups deepin-linglong | grep -qw "users"); then
gpasswd -a deepin-linglong users
fi
else
while [ $(getent passwd $useruid | wc -l) -gt 0 ]; do
useruid=$(expr $useruid + 1)
if [ $useruid -ge 499 ]; then
echo "uid400-499被占用"
fi
done
while [ $(getent group $usergid | wc -l) -gt 0 ]; do
usergid=$(expr $usergid + 1)
if [ $usergid -ge 499 ]; then
echo "gid400-499被占用"
fi
done
groupadd -g $usergid deepin-linglong
useradd -u $useruid -g deepin-linglong -s /sbin/nologin deepin-linglong
gpasswd -a deepin-linglong users
fi
chown deepin-linglong:users /usr/bin/ll-package-manager >/dev/null 2<&1
chown -R deepin-linglong:users ${LINGLONG_ROOT} >/dev/null 2<&1
if [ -d /var/log/linglong ]; then
chmod o+w /var/log/linglong
fi
sed -i '/.*store-llrepo.deepin.com.*/ c \url=https://store-llrepo.deepin.com/repos/repo' ${LINGLONG_ROOT}/repo/config
}
post_upgrade() {
post_install
}
pre_install(){
oldProfile="/etc/profile.d/linglong.sh"
oldX11Config="/etc/X11/Xsession.d/21linglong"
if [ "x$1" != "x" ]; then
killall ll-service >/dev/null 2<&1
killall ll-package-manager >/dev/null 2<&1
fi
# 这两个旧文件主要用于设置玲珑环境变量,优先级较高,而且与systemd generator功能重复,不再需要
if [[ -f "$oldProfile" && -f "$oldX11Config" ]]; then
rm $oldProfile $oldX11Config
fi
}
pre_upgrade() {
pre_install upgrade
}
|