-
Notifications
You must be signed in to change notification settings - Fork 55
/
prepare_rescue
executable file
·49 lines (39 loc) · 1.34 KB
/
prepare_rescue
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
#! /bin/sh
# ensure some trees are completely writable
for i in /etc /media /root /run /var ; do
cp -aL $i ${i}_tmp
rm -rf $i
mv ${i}_tmp $i
ln -snf /proc/self/mounts /etc/mtab
done
if [ -f /mounts/initrd/etc/suse-blinux.conf ] ; then
grep -q '^brlname=none' /mounts/initrd/etc/suse-blinux.conf || {
cp /mounts/initrd/etc/suse-blinux.conf /etc
insserv brld
insserv sbl
}
fi
if [ -e /usr/lib/systemd/system/sshd.service -a "$SSH" = 1 ] ; then
cp -f /usr/lib/systemd/system/sshd.service /etc/systemd/system
ln -s ../sshd.service /etc/systemd/system/multi-user.target.wants
fi
if [ -n "$SSHPASSWORDENC" ] ; then
echo "root:$SSHPASSWORDENC" | chpasswd -e
elif [ -n "$SSHPASSWORD" ] ; then
echo "root:$SSHPASSWORD" | chpasswd
fi
# keep some initrd config files for rescue system
cd /mounts/initrd
for i in etc/modprobe.d/blacklist etc/modprobe.d/noload etc/resolv.conf etc/sysconfig/network/* root/.ssh ; do
[ -f "$i" ] && cp -f "$i" "/$i"
[ -d "$i" ] && cp -fr --parents "$i" /
done
cd /
# create machine id
a=`dd if=/dev/urandom bs=1 count=10 2>/dev/null | md5sum` ; echo ${a%% *} >/etc/machine-id
# preserve hostname
hostname >/etc/hostname
# bash >/dev/console 2>&1
rm -f /mounts/initrd/{*,.*}
rmdir /mounts/initrd/* 2>/dev/null
rm -rf /mounts/initrd/{bin,download,etc,lbin,lib,modules,oldroot,root,sbin,scripts,tmp,usr,var}