blob: c9263840350d6dfc5f0c6b40b234c913d0a466f2 (
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
|
#!/usr/bin/env bash
# check if we are in docker by CRUPEST_IN_DOCKER
if [ "${CRUPEST_IN_DOCKER}" != "true" ]; then
echo "This script is intended to be run in a docker container."
exit 1
fi
# check if we are root
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root."
exit 1
fi
# CRUPEST_USER, CRUPEST_UID, CRUPEST_GID must be defined
if [ -z "$CRUPEST_USER" ] || [ -z "$CRUPEST_UID" ] || [ -z "$CRUPEST_GID" ]; then
echo "CRUPEST_USER, CRUPEST_UID, CRUPEST_GID must be defined."
exit 1
fi
# if we are in China (by checking USE_CHINA_MIRROR), use the mirror in China
if [ "$USE_CHINA_MIRROR" = "true" ]; then
echo "You have set USE_CHINA_MIRROR to true, using mirror ${CHINA_MIRROR_URL} (set by CHINA_MIRROR_URL) in China."
echo "Server = ${CHINA_MIRROR_URL}" > /etc/pacman.d/mirrorlist
fi
# from now on, we don't allow error
set -e
# Update the system and I need python3
pacman -Syu --noconfirm python
# execute the restore pacman config script
python3 ./restore-pacman-conf.py
# reinstall all installed packages
pacman -Qnq | pacman -S --noconfirm --overwrite=* -
# install new packages
echo "base-devel git ${CRUPEST_PACKAGES}" | tr " " "\n" | pacman -S --noconfirm --needed -
# if GROUP not defined, set it the same to USER
if [ -z "$CRUPEST_GROUP" ]; then
CRUPEST_GROUP="$CRUPEST_USER"
fi
# check if GROUP exists. if not create it with GID
if ! grep -q "^${CRUPEST_GROUP}:" /etc/group; then
groupadd -g "$CRUPEST_GID" "$CRUPEST_GROUP"
fi
# create user for UID and GID
useradd -m -u "${CRUPEST_UID}" -g "${CRUPEST_GID}" "${CRUPEST_USER}"
# add the user to sudo
echo "${CRUPEST_USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
# create data directory and change the permission
mkdir -p /data
chown "${CRUPEST_USER}":"${CRUPEST_GROUP}" /data
chmod 700 /data
|