blob: bd7157f1cfe1a109f4f967359606d4afe0d8f23d (
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
115
116
117
118
119
120
121
122
|
#!/bin/bash
# (C) Eric Thibodeau GPL v2
. /sbin/functions.sh
kernel_links()
{
einfo "====================================="
einfo "Correcting kernel and initramfs links"
einfo "====================================="
cd /boot
ln -s kernel-* vmlinuz
ln -s initramfs-* initramfs
}
unionfs_prep()
{
einfo "====================================="
einfo "=adding unionfs required dirs========"
einfo "====================================="
# for I in etc var tmp
# do
mkdir -p /mnt/rw_mounts/
# done
}
set_runlevel()
{
ln -s /etc/runlevels/default /etc/runlevels/unionfs
}
run_depmod() {
depmod -a -b /usr/src/linux
}
# We do this often in scripts to config files, change OPTION=something to OPTION=other
# in:
# $1: OPTION=other
# $2: /path/to/file.conf
# $3: (Optional) assignment token, defaults to =
# out:
# Changes are made inline
change_opt() {
SEP=${3:-=}
KEY=${1#*${SEP}}
VAL=${1%${SEP}*}
# Replace old value with the new one ;)
sed -e"s:${VAL}${SEP}.*:$1:" -i $2
}
openrc_diskless_setup() {
einfo "====================================="
einfo "=Setting up default RC configs======="
einfo "====================================="
# /etc/rc.conf
for I in 'rc_parallel="yes"' 'rc_depend_strict="NO"' 'rc_tty_number=2'
do
change_opt $I /etc/rc.conf
done
# /etc/conf.d/bootmisc
change_opt 'wipe_tmp="NO"' /etc/conf.d/bootmisc
# /etc/conf.d/net
echo 'dhcpcd_eth0="-p --inform"' >> /etc/conf.d/net
# Set clock to localtime as default
change_opt 'clock="local"' /etc/conf.d/hwclock
change_opt 'clock_systohc="YES"' /etc/conf.d/hwclock
# We don't do this anymore since it puts files into /lib64/rc/init.d/
# and that causes error messages on reboot:
#einfo "Pre-generating dependencies..."
#/lib/rc/bin/rc-depend -u
# Instead, we actually clean out that folder:
rm -Rf /lib64/rc/init.d/*
# The following is only useful if some freak grabs the livecd and is in a TZ
# making the /etc files dated in the future (my system is UTC-5
einfo "Moving dates to the past so the Cache isn't always regenerated"
find /etc/ -exec touch --date=yesterday {} \;
}
setup_services() {
# Pre-generating sshd keys can be the source of philosophical debates:
einfo "====================================="
einfo "=Pre-generating sshd keys============"
einfo "====================================="
. /etc/init.d/sshd
gen_keys
# ln -s /etc/runlevels/default /etc/runlevels/unionfs
}
dash_is_sh() {
einfo "====================================="
einfo "=Replacing sh with dash=============="
einfo "====================================="
rm /bin/sh
ln -s /bin/dash /bin/sh
}
#kernel_links
dash_is_sh
unionfs_prep
#run_depmod
openrc_diskless_setup
# this one is a hack since catalyst doesn't do it for the moment for some reason
setup_services
# TEMPORARY for testing:
einfo "====================================="
einfo "=Changing root password=============="
einfo "====================================="
echo root:test | chpasswd
exit 0
|