-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·58 lines (50 loc) · 1.69 KB
/
install.sh
File metadata and controls
executable file
·58 lines (50 loc) · 1.69 KB
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/sh -e
WRKDIR="$PWD"
LEVELS=""
STATES="custom.state graphical.state multi-user-net.state multi-user.state single-user.state"
[ "${DESTDIR: -1}" == '/' ] && DESTDIR=${DESTDIR::-1}
PREFIX="${DESTDIR}$1"
SBIN_PATH="$PREFIX/$2"
UNITS_PATH="${DESTDIR}$3"
UNITS_USER_PATH="${DESTDIR}$4"
UNITS_ENAB_PATH="${DESTDIR}$5"
UNITD_TIMER_DATA_PATH="${DESTDIR}$6"
SYSCONFDIR="${7:1}"
# Set environment variables to satisfy unitd check unit script.
export UNITS_PATH="$UNITS_PATH"
export UNITS_USER_PATH="$UNITS_USER_PATH"
export UNITS_ENAB_PATH="$UNITS_ENAB_PATH"
export UNITD_TIMER_DATA_PATH="$UNITD_TIMER_DATA_PATH"
printf "Received the following parameters:\n"
printf "DESTDIR=$DESTDIR\n"
printf "PREFIX=$PREFIX\n"
printf "SBIN_PATH=$SBIN_PATH\n"
printf "UNITS_PATH=$UNITS_PATH\n"
printf "UNITS_USER_PATH=$UNITS_USER_PATH\n"
printf "UNITS_ENAB_PATH=$UNITS_ENAB_PATH\n"
printf "UNITD_TIMER_DATA_PATH=$UNITD_TIMER_DATA_PATH \n"
printf "=> Creating symbolic link for zzz ...\n"
cd "$SBIN_PATH"
ln -sfv zzz ZZZ
printf "=> Executing unitd check unit ...\n"
cd "$WRKDIR"
../src/extra/init.state/scripts/unitd-check.sh
printf "=> Copying units ...\n"
cp -v ../units/*.unit "$UNITS_PATH"
printf "=> Enabling units ...\n"
# We have to use relative symlinks to enable units.
# Let's figure out how many levels have to go up.
cd "$UNITS_PATH"
[ -z "$DESTDIR" ] && DESTDIR="/"
while [ $(pwd) != "$DESTDIR" ]; do
cd ..
LEVELS+="../"
done
# Re-enter in UNITS_PATH to set relative symlinks.
cd "$UNITS_PATH"
for state in ${STATES[@]}; do
[ "$state" != "single-user.state" ] &&
ln -rsfv agetty-1.unit "${LEVELS}${SYSCONFDIR}/unitd/units/$state" ||
ln -rsfv sulogin.unit "${LEVELS}${SYSCONFDIR}/unitd/units/$state"
done
printf "Done!\n"