rev |
line source |
domcox@599
|
1 #!/bin/sh
|
domcox@656
|
2 # tazinst - SliTaz GNU/Linux installer.
|
domcox@599
|
3 #
|
domcox@599
|
4 # So this is the SliTaz installer. The script starts with a
|
domcox@599
|
5 # few main variables, then all the functions and then the
|
domcox@599
|
6 # full sequence of functions.
|
domcox@599
|
7 #
|
domcox@599
|
8 # (C) 2007-2011 SliTaz - GNU General Public License v3.
|
domcox@599
|
9 #
|
domcox@599
|
10 # Authors : Christophe Lincoln <pankso@slitaz.org>
|
domcox@612
|
11 # Dominique Corbex <domcox@slitaz.org>
|
domcox@654
|
12 #
|
domcox@656
|
13 # Exit codes:
|
domcox@654
|
14 # 1: Parameters error
|
domcox@654
|
15 # 2: Configuration file error
|
domcox@654
|
16 # 3: Source error
|
domcox@654
|
17 # 4: Cancelled by user
|
domcox@654
|
18 # 5: Target partition error
|
domcox@656
|
19 # 6: SliTaz system to upgrade not found
|
domcox@654
|
20 # 8: Internal error
|
domcox@599
|
21
|
domcox@661
|
22 VERSION=3.22
|
domcox@655
|
23
|
domcox@655
|
24 # Internationalization
|
domcox@655
|
25 . /usr/bin/gettext.sh
|
domcox@655
|
26 TEXTDOMAIN='tazinst'
|
domcox@655
|
27 export TEXTDOMAIN
|
domcox@612
|
28
|
domcox@599
|
29 SOURCE_ROOT=/media/source
|
domcox@599
|
30 TARGET_ROOT=/mnt/target
|
domcox@599
|
31 LOG=/var/log/tazinst.log
|
domcox@599
|
32 BACKLIST="SliTaz GNU/Linux installer"
|
domcox@599
|
33
|
domcox@654
|
34 # DEBUG=1: Enable debug msgs
|
domcox@599
|
35 DEBUG=0
|
domcox@599
|
36
|
domcox@654
|
37 # Predefined urls
|
domcox@612
|
38 URL_STABLE="http://mirror.slitaz.org/iso/stable/slitaz-4.0.iso"
|
domcox@599
|
39 URL_COOKING="http://mirror.slitaz.org/iso/cooking/slitaz-cooking.iso"
|
domcox@599
|
40 URL_ROLLING="http://mirror.slitaz.org/iso/rolling/slitaz-core.iso"
|
domcox@599
|
41
|
domcox@656
|
42 # Config
|
domcox@656
|
43 [ -r /etc/slitaz/tazinst.conf ] && . /etc/slitaz/tazinst.conf
|
domcox@656
|
44
|
domcox@599
|
45 # Print a short help
|
domcox@599
|
46 usage()
|
domcox@599
|
47 {
|
domcox@599
|
48 echo -e "\n`gettext \"Tazinst - SliTaz installer - Version\"`: $VERSION\n"
|
domcox@599
|
49 echo -e "\033[1m`gettext \"Usage\"`:"
|
domcox@656
|
50 echo -e "\033[0m `gettext \"tazinst [command] [config-file|url|options]\"`\n"
|
domcox@599
|
51 echo -e "\033[1m`gettext \"Commands\"`: \033[0m"
|
domcox@655
|
52 echo -e "usage `gettext \"Print this short usage.\"`"
|
domcox@655
|
53 echo -e "install `gettext \"Install SliTaz on HDD using a configuration file.\"`"
|
domcox@655
|
54 echo -e "upgrade `gettext \"Upgrade SliTaz on HDD using a configuration file.\"`"
|
domcox@655
|
55 echo -e "config `gettext \"Generate a configuration file.\"`"
|
domcox@658
|
56 echo -e "check `gettext \"Check validity of the configuration file.\"`"
|
domcox@656
|
57 echo -e "showurl `gettext \"Show the full URL of a predefined URL (stable|cooking|rolling).\"`"
|
domcox@661
|
58 echo -e "log `gettext \"Display log file contents.\"`"
|
domcox@655
|
59 echo -e "cli `gettext \"Install or upgrade using command line options:\"`"
|
domcox@599
|
60 echo -e " -i `gettext \"Full Install (not upgrading, all present data will be lost).\"`"
|
domcox@599
|
61 echo -e " -u `gettext \"Upgrade (Needs an active internet connection).\"`"
|
domcox@599
|
62 echo -e " -t <type> `gettext \"Install type (cdrom|usb|iso|web|weboot).\"`"
|
paul@618
|
63 echo -e " -s <source> `gettext \"Source media (ex: file.iso|usb partition|web url).\"`"
|
domcox@599
|
64 echo -e " -p <partition> `gettext \"Partition where SliTaz will be installed (ex:/dev/hda3).\"`"
|
paul@608
|
65 echo -e " -f <fs> `gettext \"Partition to be formatted (fs=ext2|ext3|ext4|etc..).\"`"
|
domcox@599
|
66 echo -e " -g `gettext \"Install Grub.\"`"
|
domcox@599
|
67 echo -e " -w `gettext \"Dual-boot a Windows partition (auto|hd<disk>,<part> ex:hd0,0).\"`"
|
domcox@599
|
68 echo -e " -d `gettext \"Debug mode.\"`"
|
domcox@599
|
69 exit 0
|
domcox@599
|
70 }
|
domcox@599
|
71
|
domcox@599
|
72 # Print an error msg & exit
|
domcox@599
|
73 # $1: exit code
|
domcox@599
|
74 # $@: err msg
|
domcox@599
|
75 abort()
|
domcox@599
|
76 {
|
domcox@599
|
77 # unmouting source & target
|
domcox@599
|
78 if mount | grep -q $SOURCE_ROOT; then
|
domcox@599
|
79 umount $SOURCE_ROOT 2>>$LOG
|
domcox@599
|
80 fi
|
domcox@599
|
81 if mount | grep -q $TARGET_ROOT; then
|
domcox@599
|
82 umount $TARGET_ROOT 2>>$LOG
|
domcox@599
|
83 fi
|
domcox@654
|
84 echo -e "`gettext \"Error\"` $@"
|
paul@608
|
85 test $(id -u) = 0 && echo "Installation cancelled on error $@" >> $LOG
|
domcox@599
|
86 exit $1
|
domcox@599
|
87 }
|
domcox@599
|
88
|
domcox@599
|
89 # Print a warning msg
|
domcox@599
|
90 warning()
|
domcox@599
|
91 {
|
domcox@654
|
92 echo -e "`gettext \"Warning:\"` $@" | tee -a $LOG
|
domcox@599
|
93 }
|
domcox@599
|
94
|
domcox@599
|
95 # Print a debug msg
|
domcox@599
|
96 debug()
|
domcox@599
|
97 {
|
domcox@599
|
98 [ $DEBUG -gt 0 ] && echo -e "\033[1mDEBUG: \033[0m$1"
|
domcox@599
|
99 echo "DEBUG: $1" >>$LOG
|
domcox@599
|
100 }
|
domcox@599
|
101
|
domcox@599
|
102 # print a msg
|
domcox@599
|
103 msg()
|
domcox@599
|
104 {
|
domcox@599
|
105 STEP=$(($STEP+1))
|
domcox@599
|
106 echo "$STEP. $@" | tee -a $LOG
|
domcox@599
|
107 }
|
domcox@599
|
108
|
domcox@599
|
109 ########################
|
domcox@599
|
110 # Gen-config functions #
|
domcox@599
|
111 ########################
|
domcox@599
|
112
|
domcox@599
|
113 # Generate a config file
|
domcox@599
|
114 # $1: Configuration file
|
domcox@599
|
115 gen_config()
|
domcox@599
|
116 {
|
domcox@599
|
117 CONFILE=$1
|
domcox@658
|
118 touch $CONFILE || abort 2 `gettext "Can't write config file"`
|
domcox@599
|
119 if [ -r "$CONFILE" ]; then
|
domcox@599
|
120 cat > $CONFILE << _EOF_
|
domcox@599
|
121 # tazinst.conf: SliTaz Installer configuration file.
|
domcox@599
|
122 #
|
domcox@599
|
123
|
domcox@599
|
124 # Install type : [cdrom|usb|iso|web|weboot]
|
domcox@599
|
125 INST_TYPE="cdrom"
|
domcox@599
|
126
|
domcox@599
|
127 # Install source
|
domcox@599
|
128 # usb:/dev/xxx, ex: SRC_FILE=/dev/sdb1
|
domcox@599
|
129 # iso:file.iso, ex: SRC_FILE=~/slitaz.3.0.iso
|
domcox@599
|
130 # web: url, ex: SRC_FILE=http://mirror.slitaz.org/iso/cooking/slitaz-cooking.iso
|
paul@618
|
131 # web: predefined mirrors (stable|cooking|rolling), ex: SRC_FILE=cooking
|
domcox@599
|
132 SRC_FILE=""
|
domcox@599
|
133
|
domcox@599
|
134 # Install Target (Root Partition).
|
domcox@599
|
135 TGT_PARTITION="/dev/hda5"
|
domcox@599
|
136
|
domcox@599
|
137 # Target File system.
|
domcox@599
|
138 # SliTaz uses ext3 by default but another filesystem can be used if wanted,
|
domcox@599
|
139 # for this please adjust your /etc/fstab after installation. Valid options are:
|
domcox@599
|
140 # (btrfs|ext2|ext3|ext4|fat16|fat32|hfs|hfs+|jfs|ntfs|reiser4|reiserfs|ufs|xfs)
|
domcox@599
|
141 TGT_FS="ext3"
|
domcox@599
|
142
|
domcox@599
|
143 # Home partition.
|
domcox@599
|
144 # On most GNU/Linux systems users personal files are stored in the directory
|
paul@618
|
145 # /home. Home can be on another hard disk or on a separate partition.
|
domcox@599
|
146 TGT_HOME=""
|
domcox@599
|
147 # Home File system (if /home is on a separate partition)
|
domcox@599
|
148 TGT_HOME_FS=""
|
domcox@599
|
149
|
domcox@599
|
150 # Hostname
|
domcox@599
|
151 TGT_HOSTNAME="slitaz"
|
domcox@599
|
152
|
domcox@599
|
153 # root password
|
domcox@599
|
154 # The root administrator privilege lets you manage and configure the full
|
domcox@599
|
155 # system. A root user can damage your system so you should always setup a
|
domcox@599
|
156 # strong password with special characters and/or numbers.
|
domcox@599
|
157 TGT_ROOT_PWD="root"
|
domcox@599
|
158
|
domcox@599
|
159 # The default user for the system will have his personal files stored
|
domcox@599
|
160 # in /home/*user* (and will be automatically added to the audio group).
|
domcox@599
|
161 TGT_USER="tux"
|
domcox@599
|
162 TGT_USER_PWD=""
|
domcox@599
|
163
|
domcox@599
|
164 # Grub bootloader
|
domcox@599
|
165 # install grub [yes|no]
|
domcox@599
|
166 TGT_GRUB="no"
|
domcox@599
|
167
|
domcox@599
|
168 # Windows dual-boot
|
domcox@599
|
169 # Dual boot is disabled if WINBOOT is empty: TGT_WINBOOT=""
|
domcox@599
|
170 # You may let tazinst find your win partition, mode=auto: TGT_WINBOOT="auto"
|
paul@618
|
171 # or use manual setting: "hd[disk],[partition]" ex:TGT_WINBOOT=hd0,0
|
domcox@599
|
172 TGT_WINBOOT=""
|
domcox@599
|
173
|
domcox@599
|
174 _EOF_
|
domcox@599
|
175
|
domcox@599
|
176 else
|
domcox@658
|
177 abort 2 `gettext "Config file not found"`
|
domcox@599
|
178 fi
|
domcox@599
|
179 }
|
domcox@599
|
180
|
domcox@599
|
181 ######################
|
domcox@599
|
182 # Checking functions #
|
domcox@599
|
183 ######################
|
domcox@599
|
184
|
domcox@599
|
185 # def values and start log
|
domcox@599
|
186 # $@ :
|
domcox@599
|
187 init()
|
domcox@599
|
188 {
|
domcox@660
|
189 echo "=== Tazinst: start at `date` ===" >$LOG
|
domcox@599
|
190 echo "Command: $0 $@" >>$LOG
|
domcox@660
|
191 debug $(fdisk -l | grep \/dev)
|
domcox@599
|
192
|
domcox@599
|
193 # Default Type
|
domcox@599
|
194 INST_TYPE=cdrom
|
domcox@599
|
195 # Default Hostname.
|
domcox@599
|
196 TGT_HOSTNAME=slitaz
|
domcox@599
|
197 # Default root passwd
|
domcox@599
|
198 TGT_ROOT_PWD=root
|
domcox@599
|
199 # Default user
|
domcox@599
|
200 TGT_USER=tux
|
domcox@599
|
201 # Default Grub Install
|
domcox@599
|
202 TGT_GRUB=no
|
domcox@599
|
203 }
|
domcox@599
|
204
|
domcox@599
|
205 # Read Conf
|
domcox@599
|
206 # $1: conf file
|
domcox@599
|
207 read_configuration_file()
|
domcox@599
|
208 {
|
domcox@599
|
209 CONFILE=$1
|
domcox@599
|
210 if [ -n "$CONFILE" ]; then
|
domcox@599
|
211 if [ -r "$CONFILE" ]; then
|
domcox@599
|
212 debug "Using config-file=$CONFILE"
|
domcox@599
|
213 # source doesn't like file without a path
|
domcox@599
|
214 [ $(echo "$CONFILE" | grep -c "/") == "0" ] && CONFILE="./$CONFILE"
|
domcox@658
|
215 source $CONFILE || abort 2 `gettext "Unable to read config file"`
|
domcox@599
|
216 else
|
domcox@658
|
217 abort 2 `gettext "Config file not found"`
|
domcox@599
|
218 fi
|
domcox@599
|
219 else
|
domcox@654
|
220 abort 2 `gettext "No configuration file provided"`
|
domcox@599
|
221 fi
|
domcox@599
|
222 }
|
domcox@599
|
223
|
domcox@599
|
224 # Cli options
|
domcox@599
|
225 # $@: tazinst parms
|
domcox@599
|
226 check_cli_options()
|
domcox@599
|
227 {
|
domcox@599
|
228 shift
|
domcox@599
|
229 while getopts "c:df:ghip:s:t:uw:" opt ; do
|
domcox@599
|
230 case $opt in
|
domcox@599
|
231 d) DEBUG=1 ;;
|
domcox@599
|
232 f) TGT_FS=$OPTARG ;;
|
domcox@599
|
233 g) TGT_GRUB="yes" ;;
|
domcox@599
|
234 h) usage ;;
|
domcox@599
|
235 i) INSTALL="install" ;;
|
domcox@599
|
236 p) TGT_PARTITION=$OPTARG ;;
|
domcox@599
|
237 s) SRC_FILE=$OPTARG ;;
|
domcox@599
|
238 t) INST_TYPE=$OPTARG ;;
|
domcox@599
|
239 u) UPGRADE="upgrade" ;;
|
domcox@599
|
240 w) TGT_WINBOOT=$OPTARG ;;
|
domcox@599
|
241 [?]) abort 1 ;;
|
domcox@599
|
242 esac
|
domcox@599
|
243 done
|
domcox@599
|
244
|
domcox@599
|
245 # Duplicate install modes are forbidden
|
domcox@654
|
246 [ -n "$INSTALL" ] && [ -n "$UPGRADE" ] && abort 1 `gettext "Mismatched parameters"`
|
domcox@599
|
247 INST_ACTION="$INSTALL$UPGRADE"
|
domcox@599
|
248 # Don't allow formatting on upgrades
|
domcox@599
|
249 [ "$INST_ACTION" == "upgrade" ] && [ -n "$TGT_FS" ] && \
|
domcox@658
|
250 warning "$TGT_PARTITION: `gettext "will not be formatted during upgrade"`"
|
domcox@599
|
251 }
|
domcox@599
|
252
|
domcox@599
|
253 # check main vars
|
domcox@599
|
254 check_vars()
|
domcox@599
|
255 {
|
domcox@599
|
256 # error handling
|
domcox@599
|
257 local error=no
|
domcox@599
|
258 local found=no
|
domcox@599
|
259 local partition=""
|
domcox@599
|
260
|
domcox@599
|
261 debug "--- Tazinst main options ---"
|
domcox@599
|
262 debug "action=$INST_ACTION"
|
domcox@599
|
263 debug "type=$INST_TYPE"
|
domcox@599
|
264 debug "source=$SRC_FILE"
|
domcox@599
|
265 debug "/ partition=$TGT_PARTITION"
|
domcox@599
|
266 debug "/ filesystem=$TGT_FS"
|
domcox@599
|
267 debug "/home partition=$TGT_HOME"
|
domcox@599
|
268 debug "/home filesystem=$TGT_HOME_FS"
|
domcox@599
|
269 debug "hostname=$TGT_HOSTNAME"
|
domcox@599
|
270 debug "root-pwd=$TGT_ROOT_PWD"
|
domcox@599
|
271 debug "user=$TGT_USER"
|
domcox@599
|
272 debug "user-pwd=$TGT_USER_PWD"
|
domcox@599
|
273 debug "grub=$TGT_GRUB"
|
domcox@599
|
274 debug "winboot=$TGT_WINBOOT"
|
domcox@599
|
275 debug "--------------------------------------"
|
domcox@599
|
276
|
domcox@599
|
277 # Check Action
|
domcox@599
|
278 case $INST_ACTION in
|
domcox@656
|
279 install|upgrade|check) ;;
|
domcox@658
|
280 *) msg "INST_ACTION=$INST_ACTION: `gettext "Invalid setting"`"; error=yes ;;
|
domcox@599
|
281 esac
|
domcox@599
|
282
|
domcox@599
|
283 # Check Type
|
domcox@599
|
284 case $INST_TYPE in
|
domcox@599
|
285 cdrom|weboot) ;;
|
domcox@599
|
286 usb|iso|web)
|
domcox@599
|
287 # We need a valid source
|
domcox@599
|
288 if [ -z "$SRC_FILE" ]; then
|
domcox@660
|
289 msg "INST_TYPE=$INST_TYPE, `gettext "but no source file is provided"`"; error=yes
|
domcox@599
|
290 fi ;;
|
domcox@658
|
291 *) msg "INST_TYPE=$INST_TYPE: `gettext "Invalid setting"`"; error=yes ;;
|
domcox@599
|
292 esac
|
domcox@599
|
293
|
domcox@599
|
294 # Check Source file
|
domcox@599
|
295 # 1. assign predefs
|
domcox@599
|
296 if [ "$INST_TYPE" == "web" ]; then
|
domcox@599
|
297 [ "$SRC_FILE" == "stable" ] && SRC_FILE=$URL_STABLE
|
domcox@599
|
298 [ "$SRC_FILE" == "cooking" ] && SRC_FILE=$URL_COOKING
|
domcox@599
|
299 [ "$SRC_FILE" == "rolling" ] && SRC_FILE=$URL_ROLLING
|
domcox@599
|
300 fi
|
domcox@599
|
301 # 2. check avail.
|
domcox@599
|
302 case $INST_TYPE in
|
domcox@599
|
303 iso)
|
domcox@599
|
304 if [ ! -r "$SRC_FILE" ]; then
|
domcox@658
|
305 msg "SRC_FILE=$SRC_FILE: `gettext "file not found"`"; error=yes
|
domcox@599
|
306 fi ;;
|
domcox@599
|
307 web)
|
domcox@656
|
308 if ! wget -sq "$SRC_FILE" 2> /dev/null ; then
|
domcox@658
|
309 msg "SRC_FILE=$SRC_FILE: `gettext "file not found on the web"`"; error=yes
|
domcox@599
|
310 fi ;;
|
domcox@599
|
311 esac
|
domcox@599
|
312
|
domcox@599
|
313 # Check Target Partition
|
domcox@599
|
314 found=no
|
domcox@599
|
315 LIST_PARTITION=$(fdisk -l | awk '/^\/dev/{printf "%s ",$1}')
|
domcox@599
|
316 for partition in $LIST_PARTITION; do
|
domcox@599
|
317 [ "$partition" == "$TGT_PARTITION" ] && found="yes"
|
domcox@599
|
318 done
|
domcox@599
|
319 if [ "$found" != "yes" ]; then
|
domcox@658
|
320 msg "TGT_PARTITION=$TGT_PARTITION: `gettext "Partition not found"`"; error=yes
|
domcox@599
|
321 fi
|
domcox@660
|
322 if [ "$TGT_PARTITION" == "$SRC_FILE" ]; then
|
domcox@660
|
323 msg $(gettext "Target and source partitions should be different."); error=yes
|
domcox@660
|
324 fi
|
domcox@599
|
325
|
domcox@599
|
326 # Check Filesystem
|
domcox@599
|
327 case $TGT_FS in
|
domcox@599
|
328 "") ;;
|
domcox@599
|
329 btrfs|ext2|ext3|ext4|fat16|fat32|hfs|hfs+|jfs|ntfs|reiser4|reiserfs|ufs|xfs)
|
domcox@599
|
330 found=no
|
domcox@599
|
331 for xdir in /sbin /usr/sbin /usr/bin; do
|
domcox@599
|
332 [ -x "$xdir/mkfs.$TGT_FS" ] && found=yes
|
domcox@599
|
333 done
|
domcox@599
|
334 if [ "$found" == "no" ]; then
|
domcox@658
|
335 msg "$TGT_FS: mkfs.$TGT_FS `gettext "is not installed."`"; error=yes
|
domcox@599
|
336 fi ;;
|
domcox@658
|
337 *) msg "TGT_FS=$TGT_FS: `gettext "Unknown filesystem"`"; error=yes ;;
|
domcox@599
|
338 esac
|
domcox@599
|
339
|
domcox@599
|
340 # Check Home partition
|
domcox@599
|
341 if [ -n "$TGT_HOME" ]; then
|
domcox@599
|
342 found=no
|
domcox@599
|
343 for partition in $LIST_PARTITION; do
|
domcox@599
|
344 [ "$partition" == "$TGT_HOME" ] && found=yes
|
domcox@599
|
345 done
|
domcox@599
|
346 if [ "$found" != "yes" ]; then
|
domcox@658
|
347 msg "TGT_HOME=$TGT_HOME: `gettext "Partition not found"`"; error=yes
|
domcox@599
|
348 fi
|
domcox@660
|
349 if [ "$TGT_HOME" == "$SRC_FILE" ]; then
|
domcox@660
|
350 msg $(gettext "/home and source partitions should be different."); error=yes
|
domcox@660
|
351 fi
|
domcox@660
|
352 if [ "$TGT_HOME" == "$TGT_PARTITION" ]; then
|
domcox@660
|
353 msg $(gettext "main and /home partitions should be different."); error=yes
|
domcox@660
|
354 fi
|
domcox@599
|
355 fi
|
domcox@599
|
356
|
domcox@599
|
357 # Check Home Filesystem
|
domcox@599
|
358 case $TGT_HOME_FS in
|
domcox@599
|
359 "") ;;
|
domcox@599
|
360 btrfs|ext2|ext3|ext4|fat16|fat32|hfs|hfs+|jfs|ntfs|reiser4|reiserfs|ufs|xfs)
|
domcox@599
|
361 found=no
|
domcox@599
|
362 for xdir in /sbin /usr/sbin /usr/bin; do
|
domcox@599
|
363 [ -x "$xdir/mkfs.$TGT_FS" ] && found=yes
|
domcox@599
|
364 done
|
domcox@599
|
365 if [ "$found" == "no" ]; then
|
domcox@658
|
366 msg "$TGT_FS: mkfs.$TGT_FS `gettext "is not installed."`"; error=yes
|
domcox@599
|
367 fi ;;
|
domcox@660
|
368 *) msg "TGT_HOME_FS=$TGT_HOME_FS: `gettext "Unknown filesystem"`"; error=yes ;;
|
domcox@599
|
369 esac
|
domcox@599
|
370
|
domcox@599
|
371 # Check Grub
|
domcox@599
|
372 case $TGT_GRUB in
|
domcox@599
|
373 yes|no) ;;
|
domcox@660
|
374 *) msg "TGT_GRUB=$TGT_GRUB: `gettext "Invalid setting"`"; error=yes ;;
|
domcox@599
|
375 esac
|
domcox@599
|
376
|
domcox@599
|
377 # Check Winboot
|
domcox@599
|
378 case $TGT_WINBOOT in
|
domcox@599
|
379 "") ;;
|
domcox@599
|
380 auto) ;;
|
domcox@599
|
381 hd[[:digit:]],[[:digit:]]) ;;
|
domcox@660
|
382 *) msg "TGT_WINBOOT=$TGT_WINBOOT: `gettext "Invalid format"`"; error=yes ;;
|
domcox@599
|
383 esac
|
domcox@599
|
384
|
domcox@599
|
385 # Stop on error
|
domcox@599
|
386 [ "$error" == "yes" ] && abort 1
|
domcox@599
|
387 }
|
domcox@599
|
388
|
domcox@599
|
389 # Exit install if user is not root.
|
domcox@599
|
390 check_root()
|
domcox@599
|
391 {
|
domcox@599
|
392 if test $(id -u) != 0 ; then
|
domcox@654
|
393 echo -e "`gettext \"You must be the root user (system administrator) to install SliTaz, \
|
domcox@654
|
394 please use 'su' to get a root SHell and restart installation.\"`"
|
domcox@599
|
395 exit 0
|
domcox@599
|
396 fi
|
domcox@599
|
397 }
|
domcox@599
|
398
|
domcox@599
|
399 # Mount cdrom
|
domcox@599
|
400 check_cdrom()
|
domcox@599
|
401 {
|
domcox@599
|
402 # Set device name
|
domcox@599
|
403 DRIVE_NAME=`cat /proc/sys/dev/cdrom/info | grep "drive name" | cut -f 3` [ -n "$DRIVE_NAME" ] || DRIVE_NAME=cdrom
|
domcox@599
|
404 CDROM=/dev/$DRIVE_NAME
|
domcox@599
|
405 # Try to mount a cdrom
|
domcox@599
|
406 if mount -t iso9660 $CDROM $SOURCE_ROOT 2>>$LOG; then
|
domcox@599
|
407 debug "Using files from cdrom ($CDROM)..."
|
domcox@599
|
408 sleep 2
|
domcox@599
|
409 else
|
domcox@658
|
410 warning "$CDROM: `gettext "Failed to mount"`"
|
domcox@599
|
411 fi
|
domcox@599
|
412 }
|
domcox@599
|
413
|
domcox@599
|
414 # Link LiveUSB
|
domcox@599
|
415 check_usb()
|
domcox@599
|
416 {
|
domcox@599
|
417 # /home is on USB dev
|
domcox@599
|
418 if [ -d /home/boot ]; then
|
domcox@599
|
419 debug "Using files from USB device..."
|
domcox@599
|
420 ln -s /home/boot $SOURCE_ROOT/boot
|
domcox@599
|
421 SOURCE_STATUS="link"
|
domcox@599
|
422 sleep 2
|
domcox@599
|
423 else
|
domcox@599
|
424 # Try to mount LiveUSB
|
domcox@599
|
425 if mount $SRC_FILE $SOURCE_ROOT 2>>$LOG; then
|
domcox@599
|
426 debug "Using files from USB device ($SRC_FILE)..."
|
domcox@599
|
427 SOURCE_STATUS="mount"
|
domcox@599
|
428 else
|
domcox@658
|
429 warning "$SRC_FILE: `gettext "Failed to mount USB device"`"
|
domcox@599
|
430 fi
|
domcox@599
|
431 fi
|
domcox@599
|
432 }
|
domcox@599
|
433
|
domcox@599
|
434 # Mount ISO file
|
domcox@599
|
435 check_iso()
|
domcox@599
|
436 {
|
domcox@599
|
437 local src_md5
|
domcox@599
|
438 # Integrity check
|
domcox@599
|
439 src_md5=$(echo $SRC_FILE | sed 's/.iso$/.md5/')
|
domcox@599
|
440 if [ -r "$src_md5" ]; then
|
domcox@599
|
441 [ $(md5sum $SRC_FILE | cut -d' ' -f1) == $(cat "$src_md5" | cut -d' ' -f1) ] || \
|
domcox@658
|
442 abort 3 "$SRC-FILE `gettext "corrupted"`"
|
domcox@599
|
443 else
|
domcox@658
|
444 warning "$SRC_FILE: `gettext "md5 file not found, unable to check integrity."`"
|
domcox@599
|
445 fi
|
domcox@599
|
446 # Try to mount ISO
|
domcox@599
|
447 if mount -o loop -t iso9660 $SRC_FILE $SOURCE_ROOT 2>>$LOG; then
|
domcox@599
|
448 debug "Using files from ISO ($SRC_FILE)..."
|
domcox@599
|
449 sleep 2
|
domcox@599
|
450 else
|
domcox@658
|
451 warning "$SRC_FILE: `gettext "Failed to mount ISO."`"
|
domcox@599
|
452 fi
|
domcox@599
|
453 }
|
domcox@599
|
454
|
domcox@599
|
455 # Source is on the web
|
domcox@599
|
456 check_web()
|
domcox@599
|
457 {
|
domcox@599
|
458 local src_md5
|
domcox@599
|
459 debug "Downloading $SRC_FILE"
|
domcox@599
|
460 if wget $SRC_FILE -P /tmp; then
|
domcox@599
|
461 debug "Download completed."
|
domcox@599
|
462 else
|
domcox@658
|
463 warning "$SRC_FILE: `gettext "Failed to download."`"
|
domcox@599
|
464 fi
|
domcox@599
|
465 src_md5=$(echo $SRC_FILE | sed 's/.iso$/.md5/')
|
domcox@599
|
466 debug "Downloading $src_md5"
|
domcox@660
|
467 wget $src_md5 -P /tmp || warning "$src_md5: `gettext "Failed to download."`"
|
domcox@599
|
468 tmpfile=$(echo $SRC_FILE | awk 'BEGIN{RS="/"}{out=$1}END{printf"%s",out}')
|
domcox@599
|
469 SRC_FILE="/tmp/$tmpfile"
|
domcox@599
|
470 check_iso
|
domcox@599
|
471 }
|
domcox@599
|
472
|
domcox@599
|
473 # We may be in Tiny Web boot mode
|
domcox@599
|
474 check_weboot()
|
domcox@599
|
475 {
|
domcox@599
|
476 if [ -d $SRC_FILE/boot ]; then
|
domcox@599
|
477 debug "Using files from HTTP device..."
|
domcox@599
|
478 ln -s $SRC_FILE/boot $SOURCE_ROOT/boot
|
domcox@599
|
479 sleep 2
|
domcox@599
|
480 else
|
domcox@654
|
481 abort 3 `gettext "Web boot files not found"`
|
domcox@599
|
482 fi
|
domcox@599
|
483 }
|
domcox@599
|
484
|
domcox@599
|
485 # set up source and check Slitaz' content
|
domcox@599
|
486 check_source()
|
domcox@599
|
487 {
|
domcox@599
|
488 debug "Creating mount point ($SOURCE_ROOT)..."
|
domcox@599
|
489 mkdir -p $SOURCE_ROOT
|
domcox@599
|
490 sleep 1
|
domcox@599
|
491 case $INST_TYPE in
|
domcox@599
|
492 cdrom)
|
domcox@599
|
493 check_cdrom ;;
|
domcox@599
|
494 usb)
|
domcox@599
|
495 check_usb ;;
|
domcox@599
|
496 iso)
|
domcox@599
|
497 check_iso ;;
|
domcox@599
|
498 web)
|
domcox@599
|
499 check_web ;;
|
domcox@599
|
500 weboot)
|
domcox@599
|
501 check_cdrom
|
domcox@599
|
502 check_web ;;
|
domcox@599
|
503 *)
|
domcox@654
|
504 abort 8 `gettext "Internal"` ;;
|
domcox@599
|
505 esac
|
domcox@599
|
506
|
domcox@599
|
507 # Exit with error msg if no rootfs.gz found.
|
domcox@599
|
508 debug "Checking installation media..."
|
domcox@599
|
509 if [ ! -f $SOURCE_ROOT/boot/rootfs.gz -a \
|
domcox@599
|
510 ! -f $SOURCE_ROOT/boot/rootfs1.gz ]; then
|
domcox@654
|
511 abort 3 `gettext "Invalid source"`
|
domcox@599
|
512 else
|
domcox@599
|
513 debug "Installation media checked ok"
|
domcox@599
|
514 fi
|
domcox@599
|
515 }
|
domcox@599
|
516
|
domcox@599
|
517 # Tiny summary
|
domcox@599
|
518 summary()
|
domcox@599
|
519 {
|
domcox@654
|
520 echo -e "`gettext \"Installation settings summary:\"`"
|
domcox@599
|
521 STEP=0
|
domcox@599
|
522
|
domcox@599
|
523 if [ "$INST_ACTION" == "install" ]; then
|
domcox@599
|
524 if [ -n "$TGT_FS" ]; then
|
domcox@658
|
525 msg "`gettext "Format root partition"` '$TGT_PARTITION' ($TGT_FS)"
|
domcox@599
|
526 fi
|
domcox@599
|
527 if [ -n "$TGT_HOME_FS" ]; then
|
domcox@658
|
528 msg "`gettext "Format /home partition"` '$TGT_HOME' ($TGT_HOME_FS)"
|
domcox@599
|
529 fi
|
domcox@658
|
530 msg "`gettext "Install SliTaz on"` '$TGT_PARTITION'. `gettext "Source:"` $INST_TYPE"
|
domcox@658
|
531 [ -n "$TGT_HOME" ] && msg "`gettext "Set Home partition to" `'$TGT_HOME'"
|
domcox@658
|
532 msg "`gettext "Set Hostname as"` '$TGT_HOSTNAME'"
|
domcox@658
|
533 msg "`gettext "Set Default user as"` '$TGT_USER'"
|
domcox@599
|
534 else
|
domcox@658
|
535 msg "`gettext "Check"` '$TGT_PARTITION'"
|
domcox@654
|
536 msg `gettext "Backup /etc, /home and the packages list"`
|
domcox@658
|
537 msg "`gettext "Upgrade SliTaz on"` '$TGT_PARTITION'. `gettext "Source:"` $INST_TYPE"
|
domcox@654
|
538 msg `gettext "Restore /etc, /home"`
|
domcox@654
|
539 msg `gettext "Upgrade additional packages."`
|
domcox@599
|
540 fi
|
domcox@599
|
541 if [ -n "$TGT_WINBOOT" ]; then
|
domcox@658
|
542 msg "`gettext "Enable Windows dual-boot"` ($TGT_WINBOOT)"
|
domcox@599
|
543 fi
|
domcox@599
|
544 if [ "$TGT_GRUB" == "yes" ]; then
|
domcox@654
|
545 msg `gettext "Install Grub"`
|
domcox@599
|
546 fi
|
domcox@599
|
547
|
domcox@654
|
548 echo -ne "`gettext \"Continue:(y/n)\"`"
|
domcox@599
|
549 read answer
|
domcox@599
|
550 case $answer in
|
domcox@655
|
551 [oOyY]) echo -e "`gettext \"Running $BACKLIST..\"`" ;;
|
domcox@654
|
552 *) abort 4 `gettext "Cancelled by user"` ;;
|
domcox@599
|
553 esac
|
domcox@599
|
554 STEP=0
|
domcox@599
|
555 }
|
domcox@599
|
556
|
domcox@599
|
557 #######################
|
domcox@599
|
558 # Installer functions #
|
domcox@599
|
559 #######################
|
domcox@599
|
560
|
domcox@599
|
561 # Mount and mkfs with progress.
|
domcox@599
|
562 prepare_install()
|
domcox@599
|
563 {
|
domcox@599
|
564 debug "Preparing target partition..."
|
domcox@612
|
565 # Target may be used
|
domcox@612
|
566 mount | grep -q $TGT_PARTITION && \
|
domcox@658
|
567 abort 5 "$TGT_PARTITION: `gettext "Partition in use"`"
|
domcox@599
|
568 # Mount point can be already used.
|
domcox@599
|
569 if mount | grep -q $TARGET_ROOT; then
|
domcox@599
|
570 umount $TARGET_ROOT 2>>$LOG
|
domcox@599
|
571 fi
|
domcox@599
|
572 sleep 2
|
domcox@599
|
573
|
domcox@599
|
574 # Formatting root partition
|
domcox@599
|
575 case $TGT_FS in
|
domcox@599
|
576 "")
|
domcox@599
|
577 debug "The partition ($TGT_PARTITION) will be cleaned..."
|
domcox@599
|
578 # ROOT_FS=$(parted /dev/hda5 print -m | grep "^1:" | cut -d':' -f5) ;;
|
domcox@599
|
579 ROOT_FS=auto ;;
|
domcox@599
|
580 *)
|
domcox@658
|
581 msg "`gettext "Formatting main partition:"` $TGT_PARTITION ($TGT_FS)"
|
domcox@599
|
582 mkfs.$TGT_FS $TGT_PARTITION >>$LOG 2>>$LOG
|
domcox@599
|
583 ROOT_FS=$TGT_FS ;;
|
domcox@599
|
584 esac
|
domcox@599
|
585 sleep 2
|
domcox@599
|
586
|
domcox@599
|
587 # Formatting /home
|
domcox@599
|
588 if [ -n "$TGT_HOME" ]; then
|
domcox@599
|
589 case $TGT_HOME_FS in
|
domcox@599
|
590 "")
|
domcox@599
|
591 debug "The partition ($TGT_HOME) will be kept..." ;;
|
domcox@599
|
592 *)
|
domcox@658
|
593 msg "`gettext "Formatting /home partition:"` $TGT_HOME ($TGT_HOME_FS)"
|
domcox@599
|
594 mkfs.$TGT_HOME_FS -L "Home" $TGT_HOME >>$LOG 2>>$LOG ;;
|
domcox@599
|
595 esac
|
domcox@599
|
596 sleep 2
|
domcox@599
|
597 fi
|
domcox@599
|
598
|
domcox@599
|
599 # Mount target.
|
domcox@599
|
600 debug "Creating mount point: $TARGET_ROOT"
|
domcox@599
|
601 mkdir -p $TARGET_ROOT >>$LOG
|
domcox@599
|
602 sleep 2
|
domcox@599
|
603
|
domcox@599
|
604 mount -t $ROOT_FS $TGT_PARTITION $TARGET_ROOT >>$LOG 2>>$LOG
|
domcox@599
|
605 if [ $(mount | grep -c "mnt/target") == "0" ]; then
|
domcox@658
|
606 abort 5 "$TGT_PARTITION: `gettext "Can't mount"`"
|
domcox@599
|
607 fi
|
domcox@599
|
608 }
|
domcox@599
|
609
|
domcox@599
|
610 # Get a clean target device (15%).
|
domcox@599
|
611 clean_target()
|
domcox@599
|
612 {
|
domcox@599
|
613 if [ -z "$TGT_FS" ]; then
|
domcox@599
|
614 # partition was not formatted
|
domcox@599
|
615 debug "Cleaning the root partition ($TGT_PARTITION)..."
|
domcox@599
|
616 # Keep /home in case of reinstall.
|
domcox@654
|
617 cd $TARGET_ROOT || abort 8 `gettext "Internal"`
|
domcox@599
|
618 for dir in *
|
domcox@599
|
619 do
|
domcox@599
|
620 case "$dir" in
|
domcox@599
|
621 home)
|
domcox@599
|
622 debug "keeping /home found on: $TGT_PARTITION"
|
domcox@599
|
623 mv home home.bak ;;
|
domcox@599
|
624 lost+found)
|
domcox@599
|
625 continue ;;
|
domcox@599
|
626 *)
|
domcox@599
|
627 debug "removing target: $dir"
|
domcox@599
|
628 rm -rf $dir 2>>$LOG ;;
|
domcox@599
|
629 esac
|
domcox@599
|
630 done
|
domcox@599
|
631 if [ -d mklost+found ]; then
|
domcox@599
|
632 mklost+found 2>>$LOG
|
domcox@599
|
633 fi
|
domcox@599
|
634 fi
|
domcox@599
|
635 sleep 2
|
domcox@599
|
636 }
|
domcox@599
|
637
|
domcox@599
|
638 # Kernel is renamed to standard vmlinuz-$VERSION.
|
domcox@599
|
639 install_kernel()
|
domcox@599
|
640 {
|
domcox@599
|
641 if [ -d /$TARGET_ROOT/lib/modules ]; then
|
domcox@599
|
642 KERNEL=$(ls /$TARGET_ROOT/lib/modules | tail -1)
|
domcox@599
|
643 KERNEL="vmlinuz-$KERNEL"
|
domcox@599
|
644 else
|
domcox@654
|
645 warning `gettext "Falling back to running kernel name.."`
|
domcox@599
|
646 KERNEL=vmlinuz-`uname -r`
|
domcox@599
|
647 fi
|
domcox@599
|
648 mkdir -p $TARGET_ROOT/boot
|
domcox@599
|
649 cp $SOURCE_ROOT/boot/bzImage $TARGET_ROOT/boot/$KERNEL
|
domcox@599
|
650 debug "install_kernel: $KERNEL"
|
domcox@599
|
651 sleep 2
|
domcox@599
|
652 }
|
domcox@599
|
653
|
domcox@599
|
654 # Copy isolinux r/w files (not syslinux, some files are read only).
|
domcox@599
|
655 copy_bootloaders()
|
domcox@599
|
656 {
|
domcox@599
|
657 if [ -d "$SOURCE/ROOT/boot/isolinux" ]; then
|
domcox@599
|
658 debug "Copy isolinux r/w files"
|
domcox@599
|
659 mkdir -p $TARGET_ROOT/boot/isolinux
|
domcox@599
|
660 cp -a $SOURCE_ROOT/boot/isolinux/*.cfg $TARGET_ROOT/boot/isolinux
|
domcox@599
|
661 cp -a $SOURCE_ROOT/boot/isolinux/*.kbd $TARGET_ROOT/boot/isolinux
|
domcox@599
|
662 cp -a $SOURCE_ROOT/boot/isolinux/*.txt $TARGET_ROOT/boot/isolinux
|
domcox@599
|
663 cp -a $SOURCE_ROOT/boot/isolinux/*.bin $TARGET_ROOT/boot/isolinux
|
domcox@599
|
664 cp -a $SOURCE_ROOT/boot/isolinux/*.msg $TARGET_ROOT/boot/isolinux
|
domcox@599
|
665 cp -a $SOURCE_ROOT/boot/isolinux/*.lss $TARGET_ROOT/boot/isolinux
|
domcox@599
|
666 cp -a $SOURCE_ROOT/boot/isolinux/*.c32 $TARGET_ROOT/boot/isolinux
|
domcox@599
|
667 fi
|
domcox@599
|
668 }
|
domcox@599
|
669
|
domcox@599
|
670 need_package()
|
domcox@599
|
671 {
|
domcox@599
|
672 [ -d /var/lib/tazpkg/installed/$1 ] || tazpkg get-install $1
|
domcox@599
|
673 }
|
domcox@599
|
674
|
domcox@599
|
675 # extract packed rootfs: squashfs or cromfs
|
domcox@599
|
676 extract_loramfs()
|
domcox@599
|
677 {
|
domcox@599
|
678 local i
|
domcox@599
|
679 for i in $(cpio -idvum 2> /dev/null); do
|
domcox@599
|
680 case "$i" in
|
domcox@599
|
681 rootfs*)
|
domcox@599
|
682 need_package squashfs
|
domcox@599
|
683 if ! unsquashfs $i ; then
|
domcox@599
|
684 need_package cromfs
|
domcox@599
|
685 unmkcromfs $i squashfs-root
|
domcox@599
|
686 fi
|
domcox@599
|
687 mv -f squashfs-root/* .
|
domcox@599
|
688 rmdir squashfs-root
|
domcox@599
|
689 rm -f $i
|
domcox@599
|
690 esac
|
domcox@599
|
691 done
|
domcox@599
|
692 }
|
domcox@599
|
693
|
domcox@599
|
694 # This is a loram rootfs.gz, skip loram bootstrap and extract
|
domcox@599
|
695 extract_first_loramfs()
|
domcox@599
|
696 {
|
domcox@599
|
697 (zcat $1 || unlzma -c $1) | cpio -i extractfs.cpio 2> /dev/null &&
|
domcox@599
|
698 ( cd / ; cpio -id ) < extractfs.cpio && rm -f extractfs.cpio
|
domcox@599
|
699 ofs=$(awk '/07070100/ { o+=index($0,"07070100"); printf "%d\n",o/4 ; exit } { o+=1+length() }' < $1)
|
domcox@599
|
700 dd if=$1 skip=$(($ofs / 1024)) bs=4k count=1 2> /dev/null | \
|
domcox@599
|
701 ( dd skip=$(($ofs % 1024)) bs=4 2> /dev/null ; \
|
domcox@599
|
702 dd if=$1 skip=$((1 + ($ofs / 1024) )) bs=4k ) | extract_loramfs
|
domcox@599
|
703 }
|
domcox@599
|
704
|
domcox@599
|
705 # Extract lzma'ed or gziped rootfs.
|
domcox@599
|
706 extract_rootfs()
|
domcox@599
|
707 {
|
domcox@599
|
708 local isloramfs
|
domcox@599
|
709 isloramfs=
|
domcox@654
|
710 cd $TARGET_ROOT || abort 8 `gettext "Internal"`
|
domcox@599
|
711 if [ -d $1/../fs/etc ]; then
|
domcox@599
|
712 # This is a tazlitobox loram (cdrom)
|
domcox@599
|
713 cp -a $1/../fs/. .
|
domcox@599
|
714 else
|
domcox@599
|
715 for i in $(ls $1/rootfs* | sort -r); do
|
domcox@599
|
716 if [ ! -d etc ]; then
|
domcox@599
|
717 if [ $( (zcat $i 2>/dev/null || lzma d $i -so) | wc -c) \
|
domcox@599
|
718 -lt $(stat -c %s $i) ]; then
|
domcox@599
|
719 # This is a tazlitobox loram (ram)
|
domcox@599
|
720 isloramfs=$i
|
domcox@599
|
721 extract_first_loramfs $i
|
domcox@599
|
722 continue
|
domcox@599
|
723 fi
|
domcox@599
|
724 fi
|
domcox@599
|
725 if [ -n "$isloramfs" ]; then
|
domcox@599
|
726 extract_loramfs < $i
|
domcox@599
|
727 continue
|
domcox@599
|
728 fi
|
domcox@599
|
729 ( zcat $i 2>/dev/null || lzma d $i -so || \
|
domcox@599
|
730 cat $i ) 2>>$LOG | cpio -idu
|
domcox@599
|
731 done 2>>$LOG > /dev/null
|
domcox@599
|
732 fi
|
domcox@599
|
733 cp /etc/keymap.conf etc
|
domcox@599
|
734 # unpack /usr (double check...)
|
domcox@599
|
735 if ls etc/tazlito | grep -q ".extract"; then
|
domcox@599
|
736 for i in etc/tazlito/*.extract; do
|
domcox@599
|
737 [ -f "$i" ] && . $i /media/cdrom
|
domcox@599
|
738 done
|
domcox@599
|
739 fi
|
domcox@599
|
740 }
|
domcox@599
|
741
|
domcox@599
|
742 # Pre configure freshly installed system (60 - 80%).
|
domcox@599
|
743 pre_config_system()
|
domcox@599
|
744 {
|
domcox@654
|
745 cd $TARGET_ROOT || abort 8 `gettext "Internal"`
|
domcox@599
|
746 # Restore backup of existing /home if exists.
|
domcox@599
|
747 # (created by prepare_target_dev)
|
domcox@599
|
748 if [ -d home.bak ]; then
|
domcox@599
|
749 debug "Restoring directory: /home..."
|
domcox@599
|
750 rm -rf home
|
domcox@599
|
751 mv home.bak home
|
domcox@599
|
752 sleep 1
|
domcox@599
|
753 fi
|
domcox@599
|
754 # Add root device to CHECK_FS in rcS.conf to check filesystem
|
domcox@599
|
755 # on each boot.
|
domcox@599
|
756 debug "Adding $TGT_PARTITION and CHECK_FS to file /etc/rcS.conf..."
|
domcox@599
|
757 sed -i s#'CHECK_FS=\"\"'#"CHECK_FS=\"$TGT_PARTITION\""# etc/rcS.conf
|
domcox@599
|
758 sleep 2
|
domcox@599
|
759 # Set hostname.
|
domcox@658
|
760 msg "`gettext "Configuring host name:"` $TGT_HOSTNAME"
|
domcox@599
|
761 echo $TGT_HOSTNAME > etc/hostname
|
domcox@599
|
762 }
|
domcox@599
|
763
|
domcox@599
|
764 # Set root passwd and create user after rootfs extraction.
|
domcox@599
|
765 users_settings()
|
domcox@599
|
766 {
|
domcox@599
|
767 cat > $TARGET_ROOT/users.sh << _EOF_
|
domcox@599
|
768 #!/bin/sh
|
domcox@654
|
769 echo "root:$TGT_ROOT_PWD" | chpasswd > /etc/null
|
domcox@599
|
770 adduser -D -H $TGT_USER
|
domcox@599
|
771
|
domcox@599
|
772 for grp in audio cdrom floppy dialout disk kmem tape tty video; do
|
domcox@599
|
773 if ! grep \$grp /etc/group | grep -q $TGT_USER ; then
|
domcox@599
|
774 grep -q \$grp /etc/group && addgroup $TGT_USER \$grp
|
domcox@599
|
775 fi
|
domcox@599
|
776 done
|
domcox@599
|
777
|
domcox@654
|
778 echo "$TGT_USER:$TGT_USER_PWD" | chpasswd > /etc/null
|
domcox@599
|
779 if [ ! -d /home/$TGT_USER ]; then
|
domcox@599
|
780 cp -a /etc/skel /home/$TGT_USER
|
domcox@612
|
781 [ -e /root/.xinitrc ] && cp /root/.xinitrc /home/$TGT_USER
|
domcox@599
|
782 mkdir -p /home/$TGT_USER/.config/slitaz
|
domcox@599
|
783 cp -a /etc/slitaz/applications.conf /home/$TGT_USER/.config/slitaz
|
domcox@656
|
784 # Set ownership
|
domcox@654
|
785 if grep -q ^users: /etc/group; then
|
domcox@654
|
786 chown -R $TGT_USER:users /home/$TGT_USER
|
domcox@654
|
787 else
|
domcox@654
|
788 chown -R $TGT_USER:$TGT_USER /home/$TGT_USER
|
domcox@654
|
789 fi
|
domcox@599
|
790 # Path for user desktop files.
|
domcox@599
|
791 for i in /home/$TGT_USER/.local/share/applications/*.desktop
|
domcox@599
|
792 do
|
domcox@599
|
793 [ -e "$i" ] && sed -i s/"user_name"/"$TGT_USER"/g \$i
|
domcox@599
|
794 done
|
domcox@599
|
795 fi
|
domcox@599
|
796 # Slim default user.
|
domcox@599
|
797 if [ -f /etc/slim.conf ]; then
|
domcox@599
|
798 sed -i s/"default_user .*"/"default_user $TGT_USER"/ \
|
domcox@599
|
799 /etc/slim.conf
|
domcox@599
|
800 fi
|
domcox@599
|
801 _EOF_
|
domcox@599
|
802 chmod +x $TARGET_ROOT/users.sh
|
domcox@599
|
803 chroot $TARGET_ROOT ./users.sh
|
domcox@599
|
804 rm $TARGET_ROOT/users.sh
|
domcox@599
|
805 sleep 2
|
domcox@599
|
806 }
|
domcox@599
|
807
|
paul@608
|
808 # /home can be on a separate partition. If default user exists in /home
|
paul@608
|
809 # we remove default file created by users_settings().
|
domcox@599
|
810 home_config()
|
domcox@599
|
811 {
|
domcox@599
|
812 debug "home_config: $TGT_HOME"
|
domcox@654
|
813 cd $TARGET_ROOT || abort 8 `gettext "Internal"`
|
domcox@599
|
814 mv home/$TGT_USER tmp
|
domcox@599
|
815 mount $TGT_HOME home
|
domcox@599
|
816 if [ -d $TARGET_ROOT/home/$TGTUSER ]; then
|
domcox@599
|
817 rm -rf tmp/$TGT_USER
|
domcox@599
|
818 else
|
domcox@599
|
819 mv tmp/$TGT_USER home
|
domcox@599
|
820 fi
|
domcox@599
|
821 echo "$TGT_HOME /home ext3 defaults 0 2" \
|
domcox@599
|
822 >> etc/fstab
|
domcox@599
|
823 umount home
|
domcox@599
|
824 }
|
domcox@599
|
825
|
domcox@599
|
826 # Search for a Windows partition
|
domcox@599
|
827 win_partition()
|
domcox@599
|
828 {
|
domcox@654
|
829 # msg `gettext "Searching for Windows"`
|
domcox@599
|
830 if [ "$TGT_WINBOOT" == "auto" ];then
|
domcox@599
|
831 WINBOOT=$(fdisk -l | awk '
|
domcox@599
|
832 BEGIN{disk=-1, found=-1, winboot=""}
|
domcox@599
|
833 {
|
domcox@599
|
834 # Counting disk
|
domcox@599
|
835 if ($1=="Disk"){disk++, part=-1}
|
domcox@599
|
836 # Counting partition
|
domcox@599
|
837 if (substr($1,1,4)=="/dev"){part++}
|
domcox@599
|
838 # Read partition Id
|
domcox@599
|
839 if ($2=="*"){Id=$6} else {Id=$5}
|
domcox@599
|
840 # Detect Windows type
|
domcox@599
|
841 if (Id=="7" || Id=="b"){
|
domcox@599
|
842 if (found){
|
domcox@599
|
843 # record 1st Windows partition found
|
domcox@599
|
844 winboot=sprintf("hd%d,%d",disk,part),found++}
|
domcox@599
|
845 }
|
domcox@599
|
846 }
|
domcox@599
|
847 END{printf "%s", winboot}')
|
domcox@599
|
848 if [ -z "$WINBOOT" ]; then
|
domcox@654
|
849 warning `gettext "No windows partition found. Dual-boot disabled"`
|
domcox@599
|
850 TGT_WINBOOT=""
|
domcox@599
|
851 fi
|
domcox@599
|
852 fi
|
domcox@599
|
853 }
|
domcox@599
|
854
|
domcox@599
|
855 # Determine GRUB partition number and GRUB disk number.
|
domcox@599
|
856 grub_partition()
|
domcox@599
|
857 {
|
domcox@599
|
858 DISK_LETTER=${TGT_PARTITION#/dev/[h-s]d}
|
domcox@599
|
859 DISK_LETTER=${DISK_LETTER%[0-9]}
|
domcox@599
|
860 GRUB_PARTITION=$((${TGT_PARTITION#/dev/[h-s]d[a-z]}-1))
|
domcox@599
|
861 for disk in a b c d e f g h
|
domcox@599
|
862 do
|
domcox@599
|
863 nb=$(($nb+1))
|
domcox@599
|
864 if [ "$disk" = "$DISK_LETTER" ]; then
|
domcox@599
|
865 GRUB_DISK=$(($nb-1))
|
domcox@599
|
866 break
|
domcox@599
|
867 fi
|
domcox@599
|
868 done
|
domcox@599
|
869 GRUB_ROOT="(hd${GRUB_DISK},${GRUB_PARTITION})"
|
domcox@599
|
870 }
|
domcox@599
|
871
|
domcox@599
|
872 # Create grub conf
|
domcox@599
|
873 grub_config()
|
domcox@599
|
874 {
|
domcox@599
|
875 grub_partition
|
domcox@612
|
876 if [ "$TGT_GRUB" == "yes" ]; then
|
domcox@612
|
877 win_partition
|
domcox@612
|
878 fi
|
domcox@599
|
879 # Create the target GRUB configuration.
|
domcox@599
|
880 mkdir -p $TARGET_ROOT/boot/grub
|
domcox@599
|
881 . /etc/locale.conf
|
domcox@599
|
882 cat > $TARGET_ROOT/boot/grub/menu.lst << _EOF_
|
domcox@599
|
883 # /boot/grub/menu.lst: GRUB boot loader configuration.
|
domcox@599
|
884 #
|
domcox@599
|
885
|
domcox@599
|
886 # By default, boot the first entry.
|
domcox@599
|
887 default 0
|
domcox@599
|
888
|
domcox@599
|
889 # Boot automatically after 8 secs.
|
domcox@599
|
890 timeout 8
|
domcox@599
|
891
|
domcox@599
|
892 # Graphical splash image.
|
domcox@599
|
893 splashimage=/boot/grub/splash.xpm.gz
|
domcox@599
|
894
|
domcox@599
|
895 # Change the colors.
|
domcox@599
|
896 #color yellow/brown light-green/black
|
domcox@599
|
897
|
domcox@599
|
898 # For booting SliTaz from : $TGT_PARTITION
|
domcox@599
|
899 #
|
domcox@599
|
900 title SliTaz GNU/Linux (cooking) (Kernel $KERNEL)
|
domcox@599
|
901 root $GRUB_ROOT
|
domcox@599
|
902 kernel /boot/$KERNEL root=$TGT_PARTITION lang=$LANG
|
domcox@599
|
903
|
domcox@599
|
904 _EOF_
|
domcox@599
|
905 if [ -n "$TGT_WINBOOT" ]; then
|
domcox@654
|
906 msg `gettext "Enabling Windows dual-boot"`
|
domcox@612
|
907 cat >> $TARGET_ROOT/boot/grub/menu.lst << _EOF_
|
domcox@599
|
908 # For booting Windows :
|
domcox@599
|
909 #
|
domcox@599
|
910 title Microsoft Windows
|
domcox@599
|
911 rootnoverify ($WINBOOT)
|
domcox@599
|
912 chainloader +1
|
domcox@599
|
913
|
domcox@599
|
914 _EOF_
|
domcox@599
|
915 fi
|
domcox@599
|
916 # log
|
domcox@599
|
917 debug "grub_config: $TARGET_ROOT/boot/grub/menu.lst"
|
domcox@599
|
918 echo "--- menu.lst -------------" >>$LOG
|
domcox@599
|
919 cat $TARGET_ROOT/boot/grub/menu.lst >>$LOG
|
domcox@599
|
920 echo "--- menu.lst -------------" >>$LOG
|
domcox@599
|
921 sleep 2
|
domcox@599
|
922 }
|
domcox@599
|
923
|
domcox@599
|
924 # Files install, calling for functions or with cmds.
|
domcox@599
|
925 install_files()
|
domcox@599
|
926 {
|
domcox@658
|
927 msg "`gettext "Installing SliTaz on"` $TGT_PARTITION"
|
domcox@599
|
928 # saving pwd
|
domcox@599
|
929 local save_pwd=$(pwd)
|
domcox@599
|
930
|
domcox@599
|
931 debug "Cleaning the root partition if necessary..."
|
domcox@599
|
932 clean_target
|
domcox@599
|
933
|
domcox@599
|
934 debug "Extracting the root system..."
|
domcox@599
|
935 extract_rootfs $SOURCE_ROOT/boot
|
domcox@599
|
936
|
domcox@599
|
937 debug "Installing the kernel..."
|
domcox@599
|
938 install_kernel
|
domcox@599
|
939
|
domcox@599
|
940 debug "Copying the bootloader syslinux/isolinux..."
|
domcox@599
|
941 copy_bootloaders
|
domcox@599
|
942
|
domcox@599
|
943 debug "Preconfiguring the system..."
|
domcox@599
|
944 pre_config_system
|
domcox@599
|
945
|
domcox@658
|
946 msg "`gettext "Configuring root and default user account:"` $TGT_USER"
|
domcox@599
|
947 users_settings
|
domcox@599
|
948
|
domcox@599
|
949 if [ "$TGT_HOME" != "" ]; then
|
domcox@658
|
950 msg "$TGT_HOME: `gettext "Configuring partition to be used as /home..."`"
|
domcox@599
|
951 home_config
|
domcox@599
|
952 sleep 2
|
domcox@599
|
953 fi
|
domcox@599
|
954
|
domcox@599
|
955 debug "Creating configuration file for GRUB (menu.lst)..."
|
domcox@599
|
956 grub_config
|
domcox@599
|
957
|
domcox@599
|
958 debug "Files installation completed"
|
domcox@599
|
959 sleep 2
|
domcox@599
|
960 # restoring pwd
|
domcox@599
|
961 cd $save_pwd
|
domcox@599
|
962 }
|
domcox@599
|
963
|
domcox@599
|
964 # GRUB info with disk name used for grub-install.
|
domcox@599
|
965 grub_install()
|
domcox@599
|
966 {
|
domcox@599
|
967 if [ "$TGT_GRUB" == "yes" ]; then
|
domcox@599
|
968 TARGET_DISK=`echo $TGT_PARTITION | sed s/"[0-9]"/''/`
|
domcox@658
|
969 msg "`gettext "Running grub-install on:"` $TARGET_DISK"
|
domcox@599
|
970 grub-install --no-floppy \
|
domcox@599
|
971 --root-directory=$TARGET_ROOT $TARGET_DISK 2>>$LOG
|
domcox@599
|
972 debug "Grub installation done..."
|
domcox@599
|
973 else
|
domcox@599
|
974 debug "Grub not installed"
|
domcox@599
|
975 fi
|
domcox@599
|
976 }
|
domcox@599
|
977
|
domcox@599
|
978 # Copy log file, umount target and eject cdrom.
|
domcox@599
|
979 umount_devices()
|
domcox@599
|
980 {
|
domcox@599
|
981 # Umount target
|
domcox@599
|
982 if mount | grep -q $TARGET_ROOT; then
|
domcox@658
|
983 echo -e "`gettext \"Unmounting target\"` ($TGT_PARTITION)..."
|
domcox@599
|
984 umount $TARGET_ROOT 2>>$LOG
|
domcox@599
|
985 fi
|
domcox@599
|
986
|
domcox@599
|
987 # Umount source
|
domcox@599
|
988 if mount | grep -q $SOURCE_ROOT; then
|
domcox@658
|
989 echo -e "`gettext \"Unmounting\"` $SOURCE_ROOT"
|
domcox@599
|
990 umount $SOURCE_ROOT
|
domcox@599
|
991 fi
|
domcox@599
|
992
|
domcox@599
|
993 # Eject cd
|
domcox@599
|
994 if [ "$INST_TYPE" == "cdrom" ]; then
|
domcox@654
|
995 echo -e "`gettext \"Ejecting cdrom...\"`"
|
domcox@599
|
996 eject
|
domcox@599
|
997 fi
|
domcox@599
|
998 sleep 2
|
domcox@599
|
999 }
|
domcox@599
|
1000
|
domcox@599
|
1001 # End of installation.
|
domcox@599
|
1002 end_of_install()
|
domcox@599
|
1003 {
|
domcox@654
|
1004 echo -e "`gettext \"Installation complete. You can now restart (reboot) \"`"
|
domcox@654
|
1005 echo -e "`gettext \"from your SliTaz GNU/Linux system.\"`"
|
domcox@599
|
1006 echo "=== Tazinst end at `date` ===" >>$LOG
|
domcox@612
|
1007 # Log files
|
domcox@658
|
1008 echo -e "`gettext \"Copying log files\"` ($LOG)..."
|
domcox@612
|
1009 cp -a $LOG $TARGET_ROOT/var/log
|
domcox@612
|
1010 sleep 2
|
domcox@612
|
1011 # umount
|
domcox@599
|
1012 umount_devices
|
domcox@599
|
1013 }
|
domcox@599
|
1014
|
domcox@599
|
1015 #####################
|
domcox@599
|
1016 # Upgrade functions #
|
domcox@599
|
1017 #####################
|
domcox@599
|
1018
|
domcox@599
|
1019 # Mount.
|
domcox@599
|
1020 prepare_upgrade()
|
domcox@599
|
1021 {
|
domcox@599
|
1022 debug "Preparing the target partition..."
|
domcox@612
|
1023 # Target may be used
|
domcox@612
|
1024 mount | grep -q $TGT_PARTITION && \
|
domcox@658
|
1025 abort 5 "$TGT_PARTITION: `gettext "Partition in use"`"
|
domcox@599
|
1026 # Mount point can be already used.
|
domcox@599
|
1027 if mount | grep -q $TARGET_ROOT; then
|
domcox@599
|
1028 umount $TARGET_ROOT 2>>$LOG
|
domcox@599
|
1029 fi
|
domcox@599
|
1030 mkdir -p $TARGET_ROOT && sleep 2
|
domcox@599
|
1031 # Mount target.
|
domcox@599
|
1032 mount $TGT_PARTITION $TARGET_ROOT >>$LOG 2>>$LOG
|
domcox@599
|
1033 if [ $(mount | grep -c "mnt/target") == "0" ]; then
|
domcox@658
|
1034 abort 5 "$TGT_PARTITION `gettext "Can't mount"`"
|
domcox@599
|
1035 fi
|
domcox@599
|
1036 }
|
domcox@599
|
1037
|
domcox@599
|
1038 # Check for a valid SliTaz
|
domcox@599
|
1039 check_release()
|
domcox@599
|
1040 {
|
domcox@599
|
1041 if [ -f $TARGET_ROOT/etc/slitaz-release ]; then
|
domcox@599
|
1042 release=`cat $TARGET_ROOT/etc/slitaz-release`
|
domcox@658
|
1043 msg "`gettext "Preparing upgrade of SliTaz release:"` $release"
|
domcox@599
|
1044 else
|
domcox@658
|
1045 abort 6 "'$TGT_PARTITION': `gettext "This partition doesn't appear to contain \
|
domcox@658
|
1046 a valid SliTaz system, the file: /etc/slitaz-release doesn't exist."`"
|
domcox@599
|
1047 fi && sleep 2
|
domcox@599
|
1048 }
|
domcox@599
|
1049
|
domcox@599
|
1050 # Backup target packages list.
|
domcox@599
|
1051 backup_files()
|
domcox@599
|
1052 {
|
domcox@654
|
1053 cd $TARGET_ROOT || abort 8 `gettext "Internal"`
|
domcox@599
|
1054 ls -1 var/lib/tazpkg/installed > home/packages-selection.list
|
domcox@599
|
1055 for dir in *
|
domcox@599
|
1056 do
|
domcox@599
|
1057 case "$dir" in
|
domcox@599
|
1058 boot)
|
domcox@599
|
1059 rm -rf boot/vmlinuz-* ;;
|
domcox@599
|
1060 home)
|
domcox@599
|
1061 mv home home.bak
|
domcox@599
|
1062 debug "keeping /home found on: $TGT_PARTITION" ;;
|
domcox@599
|
1063 etc)
|
domcox@599
|
1064 tar czf etc.tar.gz etc
|
domcox@599
|
1065 mv etc etc.bak
|
domcox@599
|
1066 debug "keeping /etc found on: $TGT_PARTITION" ;;
|
domcox@599
|
1067 var)
|
domcox@599
|
1068 if [ -d var/www ]; then
|
domcox@599
|
1069 mv var/www www.bak
|
domcox@599
|
1070 debug "keeping /var/www found on: $TGT_PARTITION"
|
domcox@599
|
1071 fi
|
domcox@599
|
1072 rm -rf var 2>>$LOG ;;
|
domcox@599
|
1073 lost+found)
|
domcox@599
|
1074 continue ;;
|
domcox@599
|
1075 *)
|
domcox@599
|
1076 debug "removing target: $dir"
|
domcox@599
|
1077 rm -rf $dir 2>>$LOG ;;
|
domcox@599
|
1078 esac
|
domcox@599
|
1079 done
|
domcox@599
|
1080 if [ -d mklost+found ]; then
|
domcox@599
|
1081 mklost+found 2>>$LOG
|
domcox@599
|
1082 fi
|
domcox@599
|
1083 sleep 2
|
domcox@599
|
1084 }
|
domcox@599
|
1085
|
domcox@599
|
1086 # Restore backups.
|
domcox@599
|
1087 restore_files()
|
domcox@599
|
1088 {
|
domcox@599
|
1089 rm -rf $TARGET_ROOT/home
|
domcox@599
|
1090 mv $TARGET_ROOT/home.bak $TARGET_ROOT/home
|
domcox@599
|
1091 rm -rf $TARGET_ROOT/etc
|
domcox@599
|
1092 mv $TARGET_ROOT/etc.bak $TARGET_ROOT/etc
|
domcox@599
|
1093 if [ -d $TARGET_ROOT/www.bak ]; then
|
domcox@599
|
1094 rm -rf $TARGET_ROOT/var/www
|
domcox@599
|
1095 mv $TARGET_ROOT/www.bak $TARGET_ROOT/var/www
|
domcox@599
|
1096 fi
|
domcox@599
|
1097 debug "backups restored: `date`"
|
domcox@599
|
1098
|
domcox@599
|
1099 # /var/lib/slitaz-installer
|
domcox@599
|
1100 mkdir -p $TARGET_ROOT/var/lib/tazinst
|
domcox@599
|
1101 mv $TARGET_ROOT/etc.tar.gz $TARGET_ROOT/var/lib/tazinst
|
domcox@599
|
1102 mv $TARGET_ROOT/home/packages-selection.list $TARGET_ROOT/var/lib/tazinst
|
domcox@599
|
1103 }
|
domcox@599
|
1104
|
domcox@599
|
1105 # Added pkgs
|
domcox@599
|
1106 install_pkgs()
|
domcox@599
|
1107 {
|
domcox@599
|
1108 # Check if the pkg is on the mirror.
|
domcox@599
|
1109 debug "Checking the availability of packages..."
|
domcox@599
|
1110 touch packages-to-install.list
|
domcox@599
|
1111 packages=0
|
domcox@599
|
1112 diff=`cat packages-selection.diff | sort`
|
domcox@599
|
1113 for pkg in $diff
|
domcox@599
|
1114 do
|
domcox@599
|
1115 if grep -q ^$pkg-[0-9] /var/lib/tazpkg/packages.list; then
|
domcox@599
|
1116 packages=$(($packages+1))
|
domcox@599
|
1117 echo "$pkg" >> packages-to-install.list
|
domcox@599
|
1118 fi
|
domcox@599
|
1119 done
|
domcox@599
|
1120
|
domcox@599
|
1121 # Calculate the percent for one package and install.
|
domcox@599
|
1122 debug "Installing any packages..."
|
domcox@599
|
1123 sleep 2
|
domcox@599
|
1124 if [ "$packages" == "0" ]; then
|
domcox@599
|
1125 debug "packages to install: 0"
|
domcox@599
|
1126 else
|
domcox@599
|
1127 onepkg=$((48/$packages))
|
domcox@599
|
1128 pct=50
|
domcox@599
|
1129 # Get-install all missing pkgs.
|
domcox@599
|
1130 for pkg in `cat packages-to-install.list`
|
domcox@599
|
1131 do
|
domcox@599
|
1132 pct=$(($pct+$onepkg))
|
domcox@599
|
1133 echo $pct
|
domcox@599
|
1134 debug "Installing: $pkg..."
|
domcox@599
|
1135 # Get install package and answer yes in case of dependencies.
|
domcox@599
|
1136 pkgname=`grep ^$pkg /var/lib/tazpkg/packages.list`
|
domcox@599
|
1137 tazpkg get $pkg >/dev/null 2>/dev/null
|
domcox@599
|
1138 yes "" | tazpkg install $pkgname.tazpkg --root=$TARGET_ROOT >/dev/null 2>/dev/null
|
domcox@599
|
1139 rm -f $pkgname.tazpkg
|
domcox@599
|
1140 done
|
domcox@599
|
1141 fi
|
domcox@599
|
1142 echo 100
|
domcox@599
|
1143 debug "Installation of packages complete..."
|
domcox@599
|
1144 sleep 2
|
domcox@599
|
1145 }
|
domcox@599
|
1146
|
domcox@599
|
1147 # Search for added pkgs
|
domcox@599
|
1148 update_pkgs()
|
domcox@599
|
1149 {
|
domcox@654
|
1150 cd $TARGET_ROOT/var/lib/tazinst || abort 8 `gettext "Internal"`
|
domcox@599
|
1151 # LiveCD packages list.
|
domcox@599
|
1152 debug "Creating package lists..."
|
domcox@599
|
1153 ls -1 $TARGET_ROOT/var/lib/tazpkg/installed > packages-source.list || exit 1
|
domcox@599
|
1154 debug "packages-source.list: done"
|
domcox@599
|
1155 # Diff
|
domcox@599
|
1156 diff packages-source.list packages-selection.list | \
|
domcox@599
|
1157 grep ^+[a-z] | sed s/^+// > packages-selection.diff
|
domcox@599
|
1158 debug "packages-selection.diff: done"
|
domcox@599
|
1159 # Get mirror list.
|
domcox@599
|
1160 tazpkg recharge >>$LOG 2>>$LOG
|
domcox@599
|
1161 if [ -f /var/lib/tazpkg/packages.list ]; then
|
domcox@599
|
1162 install_pkgs
|
domcox@599
|
1163 else
|
domcox@599
|
1164 touch packages-to-install.list
|
domcox@654
|
1165 warning `gettext "The list of available packages on the mirror could not be \
|
domcox@599
|
1166 downloaded. No missing packages will be reinstalled now, but \
|
domcox@599
|
1167 you can do so later by looking at the following list: \
|
domcox@654
|
1168 /var/lib/tazinst/packages-selection.diff"`
|
domcox@599
|
1169 fi
|
domcox@599
|
1170 sleep 2
|
domcox@599
|
1171 }
|
domcox@599
|
1172
|
domcox@599
|
1173 # Update grub conf
|
domcox@599
|
1174 grub_update()
|
domcox@599
|
1175 {
|
domcox@599
|
1176 # Backup and create a new grub menu.lst.
|
domcox@599
|
1177 if [ "$TGT_GRUB" == "yes" ]; then
|
domcox@654
|
1178 msg `gettext "Grub update"`
|
domcox@599
|
1179 mv $TARGET_ROOT/boot/grub/menu.lst \
|
domcox@599
|
1180 $TARGET_ROOT/boot/grub/menu.lst.bak 2>/dev/null
|
domcox@599
|
1181 grub_config
|
domcox@599
|
1182 fi
|
domcox@599
|
1183 }
|
domcox@599
|
1184
|
domcox@599
|
1185 # Prepare the partition to upgrade, backup, install, restore configs
|
domcox@599
|
1186 # and reinstall pkgs.
|
domcox@599
|
1187 upgrade_files()
|
domcox@599
|
1188 {
|
domcox@599
|
1189 # saving pwd
|
domcox@599
|
1190 local save_pwd=$(pwd)
|
domcox@654
|
1191 cd $TARGET_ROOT || abort 8 `gettext "Internal"`
|
domcox@599
|
1192
|
domcox@599
|
1193 debug "Searching for /etc/slitaz-release"
|
domcox@599
|
1194 check_release
|
domcox@599
|
1195
|
domcox@654
|
1196 msg `gettext "Backup /etc, /home and the packages list..."`
|
domcox@599
|
1197 backup_files
|
domcox@599
|
1198
|
domcox@658
|
1199 msg "`gettext "Upgrading SliTaz on:"` $TGT_PARTITION"
|
domcox@599
|
1200
|
domcox@599
|
1201 debug "Copying the bootloader syslinux/isolinux..."
|
domcox@599
|
1202 copy_bootloaders
|
domcox@599
|
1203
|
domcox@599
|
1204 debug "Extracting the root system..."
|
domcox@599
|
1205 extract_rootfs $SOURCE_ROOT/boot
|
domcox@599
|
1206
|
domcox@654
|
1207 msg `gettext "Restoring configuration files..."`
|
domcox@599
|
1208 restore_files
|
domcox@599
|
1209
|
domcox@599
|
1210 debug "Installing the kernel..."
|
domcox@599
|
1211 install_kernel
|
domcox@599
|
1212
|
domcox@654
|
1213 msg `gettext "Upgrading added packages..."`
|
domcox@599
|
1214 update_pkgs
|
domcox@599
|
1215
|
domcox@599
|
1216 # restoring pwd
|
domcox@599
|
1217 cd $save_pwd
|
domcox@599
|
1218 }
|
domcox@599
|
1219
|
domcox@599
|
1220 # End of system upgrade.
|
domcox@599
|
1221 end_of_upgrade()
|
domcox@599
|
1222 {
|
domcox@599
|
1223 pkgscd=`cat $TARGET_ROOT/var/lib/tazinst/packages-source.list | wc -l`
|
domcox@599
|
1224 pkginst=`cat $TARGET_ROOT/var/lib/tazinst/packages-to-install.list | wc -l`
|
domcox@654
|
1225 echo -e "`gettext \"Upgrade finished. You can now restart (reboot) from your SliTaz GNU/Linux system.\"`"
|
domcox@654
|
1226 echo -e "`gettext \"Packages on the cdrom :\"`" $pkgscd
|
domcox@654
|
1227 echo -e "`gettext \"Packages installed from the mirror :\"`" $pkginst
|
domcox@599
|
1228 echo "=== Tazinst end at `date` ===" >>$LOG
|
domcox@599
|
1229 umount_devices
|
domcox@599
|
1230 }
|
domcox@599
|
1231
|
domcox@599
|
1232 ######################
|
domcox@599
|
1233 # Installer sequence #
|
domcox@599
|
1234 ######################
|
domcox@599
|
1235
|
domcox@599
|
1236 case $1 in
|
domcox@599
|
1237 install)
|
domcox@599
|
1238 INST_ACTION=install
|
domcox@599
|
1239 check_root
|
domcox@599
|
1240 init $@
|
domcox@599
|
1241 read_configuration_file $2
|
domcox@599
|
1242 check_vars
|
domcox@599
|
1243 check_source
|
domcox@599
|
1244 prepare_install
|
domcox@599
|
1245 install_files
|
domcox@599
|
1246 grub_install
|
domcox@599
|
1247 end_of_install ;;
|
domcox@599
|
1248 upgrade)
|
domcox@599
|
1249 INST_ACTION=upgrade
|
domcox@599
|
1250 check_root
|
domcox@599
|
1251 init $@
|
domcox@599
|
1252 read_configuration_file $2
|
domcox@599
|
1253 check_vars
|
domcox@599
|
1254 check_source
|
domcox@599
|
1255 prepare_upgrade
|
domcox@599
|
1256 upgrade_files
|
domcox@599
|
1257 grub_update
|
domcox@599
|
1258 end_of_upgrade ;;
|
domcox@599
|
1259 config)
|
domcox@599
|
1260 gen_config $2 ;;
|
domcox@599
|
1261 cli)
|
domcox@599
|
1262 check_root
|
domcox@599
|
1263 init $@
|
domcox@599
|
1264 check_cli_options $@
|
domcox@599
|
1265 check_vars
|
domcox@599
|
1266 check_source
|
domcox@599
|
1267 summary
|
domcox@599
|
1268 case $INST_ACTION in
|
domcox@599
|
1269 upgrade)
|
domcox@599
|
1270 prepare_upgrade
|
domcox@599
|
1271 upgrade_files
|
domcox@599
|
1272 grub_update
|
domcox@599
|
1273 end_of_upgrade ;;
|
domcox@599
|
1274 install)
|
domcox@599
|
1275 prepare_install
|
domcox@599
|
1276 install_files
|
domcox@599
|
1277 grub_install
|
domcox@599
|
1278 end_of_install ;;
|
domcox@599
|
1279 esac ;;
|
domcox@656
|
1280 showurl)
|
domcox@656
|
1281 case $2 in
|
domcox@656
|
1282 stable)
|
domcox@656
|
1283 echo $URL_STABLE ;;
|
domcox@656
|
1284 cooking)
|
domcox@656
|
1285 echo $URL_COOKING ;;
|
domcox@656
|
1286 rolling)
|
domcox@656
|
1287 echo $URL_ROLLING ;;
|
domcox@656
|
1288 esac ;;
|
domcox@656
|
1289 check)
|
domcox@656
|
1290 LOG="/dev/null"
|
domcox@656
|
1291 INST_ACTION=check
|
domcox@656
|
1292 check_root
|
domcox@656
|
1293 init $@
|
domcox@656
|
1294 read_configuration_file $2
|
domcox@656
|
1295 check_vars ;;
|
domcox@661
|
1296 log)
|
domcox@661
|
1297 cat $LOG ;;
|
domcox@657
|
1298 version)
|
domcox@657
|
1299 echo $VERSION ;;
|
domcox@599
|
1300 usage|*)
|
domcox@599
|
1301 usage ;;
|
domcox@599
|
1302 esac
|
domcox@599
|
1303
|
domcox@599
|
1304 exit 0
|