summaryrefslogtreecommitdiffstats
path: root/src/initramfs/distro-specs/suse/functions-12.1
blob: 3b05ca2d17a6973d2a2d1f04e57ca017975760f7 (plain) (blame)
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
123
124
125
# Copyright (c) 2011 - OpenSLX GmbH
#
# This program/file is free software distributed under the GPL version 2.
# See http://openslx.org/COPYING
#
# If you have any feedback please consult http://openslx.org/feedback and
# send your feedback to feedback@openslx.org
#
# General information about OpenSLX can be found under http://openslx.org
#
# configuration script for OpenSuSE 12.1 to configure linux stateless clients
# (included by init, hwautocfg, servconfig within InitialRamFS after 
# inclusion of the main functions file). This file is the main base for the
# several SuSE distro versions

# settings of central variables (formerly done via config-*, these variables
# are disputable ...)
# D_DIRINBINDMNT - lists of directories to be created in bind mounted rw
# part of the client filesystem
# D_RODIRSINRW - ReadOnly Directories in RW part of filesystem to save on 
# TempFS usage
# D_DIRINDXS - directories in client filesystem which should be present 
# anyhow

# distro specific function called from servconfig script
config_distro () {
# clean the runlevel directories which will be populated by the stage3 setup
rm -rf /mnt/etc/init.d*
touch /mnt/var/log/btmp
touch /mnt/var/log/lastlog
SERVICES="systemd-hostnamed.service dbus-org.freedesktop.hostname1.service \
            remount-rootfs.service avahi-dnsconfd.service fsck* \
            Network* postfix* *.wants/Network* \
            *.wants/remote* *.wants/YaST2*";
# translate wildcards
SERVICES_LIB=$(cd /mnt/lib/systemd/system/ && for f in $SERVICES; do echo $f; done| grep -v '*')
SERVICES_ETC=$(cd /mnt/etc/systemd/system/ && for f in $SERVICES; do echo $f; done| grep -v '*')
SERVICES=$(echo -e "$SERVICES_ETC\n$SERVICES_LIB" | sort -u)
for file in $SERVICES;
do 
 ln -sf /dev/null /mnt/etc/systemd/system/${file}
done

# enable magic sysrequest for the clients
sed -e "1i# /etc/sysctl.conf - modified by $0 version $version" \
    -e "s,kernel.sysrq =.*,kernel.sysrq = 1," \
    -i /mnt/etc/sysctl.conf

}


# linking runlevel scripts
rllinker () {
local script="$1"
# empty runlevel links - decision on running certain services is
# passed via configuration
if [ -f /mnt/etc/systemd/system/${script}.service ]; then
  ln -sf /etc/systemd/system/${script}.service \
         /mnt/etc/systemd/system/default.target.wants/${script}.service
else if [ -f /mnt/lib/systemd/system/${script}.service ]; then
  ln -sf /lib/systemd/system/${script}.service \
         /mnt/etc/systemd/system/default.target.wants/${script}.service
fi
}


# start portmapper (needed at least for nfs and nis services)
config_portmap () {
# portmap is provided via rpcbind in suse 11.1,2,3,4 and 12.1
testmkd /mnt/var/lib/rpcbind
rllinker "rpcbind" 4 5
}
# acpi and powersave daemons, required e.g. to shutdown the machine via
# power button, no need for early start
config_acpi () {
rllinker acpid 22 12
# dbus is required to run acpid and powersaved
start_dreshal="yes"
}
# configure dbus (inter application communication for kde and gnome), hal
# (hardware abstraction layer - used e.g. by powersaved)
config_dreshal () {
if [ "x$start_dreshal" = "xyes" ]; then
  # create directories and set permissions with user and group id
  for dir in "/var/lib/misc" "/var/run/ConsoleKit" \
             "/var/lib/dbus" \
             "/var/lib/polkit-1/localauthority" \
             "/var/run/dbus messagebus:messagebus" \
             "/var/cache/hald haldaemon:haldaemon"; do
    testmkd /mnt${dir}
  done
  touch /mnt/var/lib/misc/PolicyKit.reload
  chown polkituser.polkituser /mnt/var/lib/misc/PolicyKit.reload

  if [ -f /mnt/etc/init.d/dbus ] ; then
    strinfile "messagebus:" /mnt/etc/passwd || \
      echo "messagebus:x:102:103:User for D-BUS:/var/run/dbus:/bin/false" \
        >> /mnt/etc/passwd
    strinfile "messagebus:" /mnt/etc/group || \
      echo "messagebus:!:103:" >> /mnt/etc/group

    rm -rf /mnt/etc/dbus-1/system.d/*etwork*anager.conf \
           /mnt/etc/dbus-1/system.d/nm-*

    rllinker "dbus" 1 20
  fi
fi
}
# function for ntp configuration
config_ntp () {
if [ -e /mnt/etc/init.d/ntp ] ; then
  if ! strinfile "ntp:" /mnt/etc/passwd ; then
    echo -e "ntp:x:74:106:NTP daemon:/var/lib/nobody:/bin/false" \
      >>/mnt/etc/passwd
    echo -e "ntp:!:13099:0:99999:7:::" >>/mnt/etc/shadow
  fi
  testmkd /mnt/var/lib/ntp/var/run/ntp
  testmkd /mnt/var/db
  touch /mnt/var/db/ntp-kod
  if [ "x$start_ntp" = "xyes" ] ; then
    rllinker "ntp" 2 14
  fi
fi
}