1 | #!/bin/sh |
---|
2 | # |
---|
3 | # SURFsara install script for LISA nodes: |
---|
4 | # Initial Authors: Bas van der Vlies and Jaap Dijkshoorn |
---|
5 | # |
---|
6 | # SVN Info: |
---|
7 | # $Id: masterscript.new 570 2013-04-19 07:09:49Z dennis $ |
---|
8 | |
---|
9 | # Pull in variables left behind by the linuxrc script. |
---|
10 | # This information is passed from the linuxrc script on the autoinstall media |
---|
11 | # via /tmp/variables.txt. |
---|
12 | # |
---|
13 | #set -x |
---|
14 | |
---|
15 | . /tmp/variables.txt |
---|
16 | |
---|
17 | # Load functions and other variables |
---|
18 | . /etc/init.d/functions |
---|
19 | |
---|
20 | ## Checking if we are using grub legacy or grub2. |
---|
21 | ## if grub2 is used the disk are set with label gpt |
---|
22 | |
---|
23 | if [ "$GRUB2" == "yes" ]; then |
---|
24 | DISKLABEL=gpt |
---|
25 | else |
---|
26 | DISKLABEL=msdos |
---|
27 | fi |
---|
28 | |
---|
29 | get_arch |
---|
30 | |
---|
31 | NO_LISTING=yes |
---|
32 | if [ -z $NO_LISTING ]; then |
---|
33 | VERBOSE_OPT="v" |
---|
34 | else |
---|
35 | VERBOSE_OPT="" |
---|
36 | fi |
---|
37 | |
---|
38 | # Remove .master from script name |
---|
39 | # |
---|
40 | SARA_IMAGE=`echo $0 | cut -d. -f1` |
---|
41 | |
---|
42 | echo $0 |
---|
43 | echo $IMAGENAME |
---|
44 | |
---|
45 | [ -z $IMAGENAME ] && IMAGENAME=`basename $SARA_IMAGE` |
---|
46 | [ -z $OVERRIDES ] && OVERRIDES=`basename $SARA_IMAGE` |
---|
47 | |
---|
48 | echo $IMAGENAME |
---|
49 | export IMAGENAME |
---|
50 | save_param IMAGENAME "${IMAGENAME}" |
---|
51 | |
---|
52 | ## Sort disk, first disk to be found are sd* disk |
---|
53 | # |
---|
54 | disk_enumerate "sd hd vd cciss" |
---|
55 | |
---|
56 | ## Begin disk creation and mounting |
---|
57 | # Create disk label. This ensures that all remnants of the old label, whatever |
---|
58 | # type it was, are removed and that we're starting with a clean label. |
---|
59 | logmsg "set_disklabel $DISK0 $DISKLABEL" |
---|
60 | set_disklabel $DISK0 $DISKLABEL |
---|
61 | |
---|
62 | if [ "$DISKLABEL" == "msdos" ]; then |
---|
63 | logmsg "partition $DISK0 1024:ext2.128:/boot:boot 1:none 4096:swap::swap 0:xfs:/:root" |
---|
64 | partition $DISK0 1024:ext2.128:/boot:boot 4096:swap::swap 0:xfs:/:root |
---|
65 | else |
---|
66 | logmsg "partition $DISK0 1024:ext2:/boot:boot 1:grub2 4096:swap::swap 0:xfs:/:root" |
---|
67 | partition $DISK0 1024:ext2:/boot:boot 1:grub2 4096:swap::swap 0:xfs:/:root |
---|
68 | fi |
---|
69 | |
---|
70 | if [ ! -z $DISK1 ] |
---|
71 | then |
---|
72 | logmsg "set_disklabel $DISK1 $DISKLABEL" |
---|
73 | set_disklabel $DISK1 $DISKLABEL |
---|
74 | |
---|
75 | logmsg "partition $DISK1 0:xfs:/scratch:scratch" |
---|
76 | partition $DISK1 0:xfs:/scratch:scratch |
---|
77 | fi |
---|
78 | |
---|
79 | logmsg "mount_disks" |
---|
80 | mount_disks |
---|
81 | |
---|
82 | ## End disk creation and mounting |
---|
83 | |
---|
84 | ### BEGIN mount proc in image for tools like System Configurator ### |
---|
85 | ### BEGIN mount sysfs in image for tools that might be run during chroot ### |
---|
86 | logmsg "chroot_mount_system_fs" |
---|
87 | chroot_mount_system_fs |
---|
88 | ### END mount proc in image for tools like System Configurator ### |
---|
89 | ### END mount sysfs in image for tools that might be run during chroot ### |
---|
90 | |
---|
91 | ################################################################################ |
---|
92 | # |
---|
93 | # Lay the image down on the freshly formatted disk(s) |
---|
94 | # |
---|
95 | if [ ! -z $MONITOR_SERVER ]; then |
---|
96 | start_report_task |
---|
97 | fi |
---|
98 | |
---|
99 | ## Let's get the image |
---|
100 | # TODO: rewrite this so we can use PROTOCOL instead of using BITTORRENT yes/no |
---|
101 | logmsg "getimage" |
---|
102 | getimage |
---|
103 | |
---|
104 | # Leave notice of which image is installed on the client |
---|
105 | echo $IMAGENAME > /a/root/IMAGE_LAST_SYNCED_TO || shellout |
---|
106 | |
---|
107 | if [ "$GRUB2" == "yes" ] |
---|
108 | then |
---|
109 | grub2_install $DISK0 |
---|
110 | fi |
---|
111 | |
---|
112 | # |
---|
113 | ################################################################################ |
---|
114 | |
---|
115 | |
---|
116 | ################################################################################ |
---|
117 | # |
---|
118 | # Post Install Scripts |
---|
119 | # |
---|
120 | |
---|
121 | run_post_install_scripts |
---|
122 | |
---|
123 | # |
---|
124 | ################################################################################ |
---|
125 | |
---|
126 | ################################################################################ |
---|
127 | # |
---|
128 | # Save virtual console session in the imaged client |
---|
129 | # |
---|
130 | if [ ! -z $MONITOR_SERVER ]; then |
---|
131 | if [ "x$MONITOR_CONSOLE" = "xyes" ]; then |
---|
132 | [ ! -d /a/root ] && mkdir -p /a/root |
---|
133 | cp -f /var/log/sali.log /a/root/sali.log |
---|
134 | fi |
---|
135 | fi |
---|
136 | |
---|
137 | # |
---|
138 | ################################################################################ |
---|
139 | |
---|
140 | ################################################################################ |
---|
141 | # |
---|
142 | # Unmount filesystems |
---|
143 | # |
---|
144 | |
---|
145 | logmsg "chroot_umount_system_fs" |
---|
146 | chroot_umount_system_fs |
---|
147 | |
---|
148 | logmsg "umount_disks" |
---|
149 | umount_disks |
---|
150 | |
---|
151 | # |
---|
152 | ################################################################################ |
---|
153 | |
---|
154 | |
---|
155 | ################################################################################ |
---|
156 | # |
---|
157 | # Tell the image server we are done |
---|
158 | # |
---|
159 | rsync $IMAGESERVER::scripts/imaging_complete > /dev/null 2>&1 |
---|
160 | logmsg "Imaging completed" |
---|
161 | # |
---|
162 | ################################################################################ |
---|
163 | |
---|
164 | reboot |
---|