-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild
More file actions
executable file
·82 lines (76 loc) · 1.66 KB
/
build
File metadata and controls
executable file
·82 lines (76 loc) · 1.66 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
DEPENDENCIES=(
coreutils
systemd
tmux
vim-minimal
)
#copy-to-rootfs
cpfs() {
local target=rootfs/${2#/}
local filename=$(basename $1)
[[ ! -a $1 ]] && {
echo "source does not exist: $1"
exit 1
}
[[ -f $target ]] && {
echo "target exists but is not a directory: $2"
exit 1
}
[[ ! -a $target ]] && {
mkdir -p $target
}
cp $1 $target/${3:-$filename}
}
prepare_rootfs() {
cpfs systemux-tmux@.service /etc/systemd/system
cpfs systemux.service /etc/systemd/system
cpfs systemux.target /etc/systemd/system
cpfs hello /bin
cpfs tmux.conf /usr/share/systemux
cpfs systemux-generator /etc/systemd/system-generators
cpfs 10-kernel-quiet.conf /etc/sysctl.d
cpfs rescue_passwordless.conf /etc/systemd/system/rescue.service.d override.conf
systemctl --root rootfs set-default systemux.target
}
check_root() {
[[ $EUID -ne 0 ]] && {
echo "run as root user"
exit 1
}
}
main_method() {
check_root
local OPTIND OPTARG OPTION
local full=false
local img=false
while getopts "fi" OPTION; do
case "${OPTION}" in
f)
full=true
;;
i)
img=true
;;
esac
done
$full || [[ ! -a rootfs ]] && {
rm -rf rootfs
mkdir -p rootfs
local S
for S in proc sys; do
mkdir -p rootfs/$S
mount --bind /$S rootfs/$S
done
dnf -y --use-host-config --installroot $(realpath rootfs) install ${DEPENDENCIES[@]}
for S in proc sys; do
umount rootfs/$S
done
}
prepare_rootfs
$img || [[ ! -a systemux-$(uname -r).img ]] && {
rm -f systemux-$(uname -r).img
mksquashfs rootfs systemux-$(uname -r).img
}
}
return 2> /dev/null || main_method $@