source: pkg/main/parsix-installer/trunk/parsix-installer @ 2458

Revision 2458, 35.1 KB checked in by alanbach-guest, 6 years ago (diff)
  • Removed lilo related functions, lilo is not supported anymore, * Removed system_fix_menus, not needed anymore, * appendGrubForOtherOS, try to be quiet, * Updated man page, * Some minor clean-ups
Line 
1#!/bin/bash
2#
3# Installs Parsix to harddisk
4#
5# GPL
6#
7# Authors:
8#               Fabian Franz <knoppix-installer@fabian-franz.de>
9#               Joerg Schirottke <master@kanotix.de>
10#       Stefan Lippers-Hollmann <s.l-h@gmx.de>
11#       Alan Baghumian <alan@technotux.org>
12#               Andreas Loibl <andreas@andreas-loibl.de>
13#
14# Based on work by Christian Perle & Klaus Knopper
15#
16
17#
18# Constants
19#
20
21VERSION="0.81.2"
22CONFIG_FILE="$HOME/.knofig"
23LOG="$HOME/.knofig_log"
24
25TARGET_MNT_POINT="/media/hdinstall" # TR1 in old installer
26TARGET_MNT_NAME="hdinstall" # TR1 in old installer
27
28# make use of distro-defaults
29if [ -f /etc/defaults/distro ]; then
30        source /etc/defaults/distro
31
32        [ -n "$FLL_LIVE_USER" ] && DEFAULT_USER="$FLL_LIVE_USER" || DEFAULT_USER="parsix"
33        [ -n "$FLL_MEDIA_DIR" ] && DEFAULT_DIR="$FLL_MEDIA_DIR"  || DEFAULT_DIR="PARSIX"
34else
35        DEFAULT_USER="parsix"
36        DEFAULT_DIR="PARSIX"
37fi
38
39DEFAULT_NAME=$(getent passwd "$DEFAULT_USER" | cut -f5 -d: | cut -f1 -d,)
40
41# It's Parsix/Kanotix
42INSTALL_KANO="yes"
43
44
45[ -f /proc/cmdline ] || mount -t proc proc /proc 2>/dev/null
46
47MEM_SWAP_NEEDED=$((512*1000)) # need some lower so that people with 512 MB can use this option
48SWAP_MIN=$((128*1024))
49if grep -q unionfs /proc/mounts; then
50        ROOT_MIN_RAW=$(du -sm "/$DEFAULT_DIR" | awk '{print $1}')
51else
52        ROOT_MIN_RAW=$(df -m "/$DEFAULT_DIR" | tail -1 | awk '{print $3}')
53        grep -q squashfs /proc/mounts && ROOT_MIN_RAW=$(($ROOT_MIN_RAW*270/100)) #fix status bar for squashfs
54fi
55ROOT_MIN_CORR=$[ROOT_MIN_RAW*115/100] # + 15% Filesystem overhead
56ROOT_MIN=$(($ROOT_MIN_CORR*1024))
57
58# Localisation
59export TEXTDOMAINDIR="/usr/share/locale"
60export TEXTDOMAIN=parsix-installer
61
62#
63# Include needed Bash-Modules
64#
65
66SEARCHPATH="/usr/share/parsix-installer"
67[ -f ./modules/00-parsix-utils.bm ] && SEARCHPATH="."
68
69[ "$SEARCHPATH" = "." ] && chown -R root:root .
70
71for i in $(find $SEARCHPATH -name "*.bm"); do
72        source $i
73done
74
75#
76# Main program
77#
78
79clean_exit(){
80        [ -n "$TMPDIR" ] && rm -rf "$TMPDIR"
81        logit $"parsix-installer terminated"
82        logit
83}
84
85trap clean_exit EXIT
86
87function logit
88{
89        TIME=$(date)
90        [ -n "$*" ] && echo $TIME: "$@" >> $LOG || echo >> $LOG
91}
92
93function exit_proc
94{
95        unset IFS
96        $DIALOG --backtitle "$BT" --title $"Save configuration?" --yesno $"Do you want to save your configuration?" 10 60
97        RC=$?
98        [ $RC -eq 0 ] && save_config $CONFIG_FILE # save of configuration
99        [ $RC -ne 255 ] && exit 0
100        RC=0
101}
102
103function setup_dialog_messages()
104{
105        MAX=5 # number of steps
106
107        BT=$"Parsix GNU/Linux Installation"" (v$VERSION)"
108        DT=$"Installation of Parsix GNU/Linux to harddisk (Step 0/$MAX)"
109        INIT_T=$"Parsix GNU/Linux installation"
110        T1=$INIT_T
111        ET=$"Installation failed"
112        ST=$"Installation successfull"
113        FATAL_DIALOG=$"Fatal dialog error"
114
115        N=1; # Step 1
116}
117
118setup_dialog "parsix-installer" # FIXME! Check for Commandline-Params
119setup_dialog_messages
120
121#
122# Variables and Config File Management
123#
124
125function add_var
126{
127        case "$REGISTERED" in *$1*) return 1;; esac
128        REGISTERED="$REGISTERED $1"
129}
130
131function register_vars
132{
133        for i in $@; do
134                add_var "$i"
135        done
136}
137
138#
139# Syntax: base, comment, allowed, checkfunc, default
140#
141
142function register_var
143{
144        export $1"_COMMENT"="$2"
145        export $1"_ALLOWED"="$3"
146        export $1"_CHECKIT"="$4"
147        export $1"_DEFAULT"="$5"
148        [ -z "${!1}" -a -n "$5" ] && export $1="$5"
149}
150
151function update_status
152{
153        echo -e "XXX\n$*\nXXX"
154        logit "$*"
155}
156
157function final_cleanup
158{
159        # disable auto-login, KDM and GDM
160        if [ -f /etc/init.d/gdm ]; then
161                sed -i  -e "s/AutomaticLoginEnable=true//" \
162                        -e "s/AutomaticLogin=parsix//" \
163                                $TARGET_MNT_POINT/etc/gdm/gdm.conf
164        elif [ -f /etc/init.d/kdm ]; then
165                sed -i  -e "s/AutoReLogin=1true//" \
166                        -e "s/AutoLoginEnable=true//" \
167                        -e "s/AutoLoginAgain=true//" \
168                        -e "s/AutoLoginDelay=1//" \
169                        -e "s/AutoLoginUser=parsix//" \
170                                $TARGET_MNT_POINT/etc/kde3/kdm/kdmrc
171        fi
172
173        # some clean-ups
174        rm -rf $TARGET_MNT_POINT/none/
175        rm -rf $TARGET_MNT_POINT/rr_moved/
176        rm -f $TARGET_MNT_POINT/boot/message
177
178        # cleaning unwanted links
179        if [ -x $TARGET_MNT_POINT/etc/rcS.d/S00live-autoconfig ]; then
180                rm -f $TARGET_MNT_POINT/etc/rcS.d/S00live-autoconfig
181        fi
182        if [ -x $TARGET_MNT_POINT/etc/rc6.d/S90live-reboot ]; then
183                rm -f $TARGET_MNT_POINT/etc/rc6.d/S90live-reboot
184        fi
185        if [ -x $TARGET_MNT_POINT/etc/rc0.d/S90live-halt ]; then
186                rm -f $TARGET_MNT_POINT/etc/rc0.d/S90live-halt
187        fi
188       
189        if [ -x $TARGET_MNT_POINT/etc/rc5.d/S80xprep ]; then
190                rm -f $TARGET_MNT_POINT/etc/rc5.d/S80xprep
191        fi
192
193        for x in $TARGET_MNT_POINT/home/*
194        do
195                if [ -f  $TARGET_MNT_POINT/home/$x/Desktop/parsix-installer.desktop ]; then
196                        rm -f $TARGET_MNT_POINT/home/$x/Desktop/parsix-installer.desktop
197                fi
198        done
199}
200
201
202#
203# FIXME: This management sucks!
204#
205
206# Beware: The real modules are set by module_system_set_modules
207
208MODULES=(hd swap name user userpass rootpass host services boot system)
209NUM_MODULES=${#MODULES[@]}
210MODULES_AUTO="swap services"
211MODULES_NUMAUTO=$(echo $MODULES_AUTO | wc -w | tr -d ' ')
212MODULES_LOAD="hd swap services boot system"
213
214function create_config
215{
216        T1=$"Choose System Type"
217 
218        # Configure system as the _very_ first
219        # TODO: How to get back there ...
220
221        module_system 0 || return 1
222        if [ "$SYSTEM_MODULE" == "configured" ]; then
223                # Set MODULES / NUM_MODULES for the configured system type.
224                module_system_set_modules
225        fi
226 
227        NUM_REAL_MODULES=$[$NUM_MODULES-$MODULES_NUMAUTO]
228        T1=$"Creating Parsix GNU/Linux Configuration Step (0/$NUM_REAL_MODULES)"
229        N=1
230        I=0
231        DIR=0
232        while [ "$I" -lt "$NUM_MODULES" ]; do
233                "module_${MODULES[$I]}" $DIR
234                RC=$?
235                DIR=0
236                [ $RC -eq 1 ] && DIR=-1
237                [ $RC -eq 0 ] && DIR=1
238                I=$[$I+$DIR]
239                [ $I -lt 0 ] && return 1
240                stringinstring "${MODULES[$I]}" "$MODULES_AUTO" || N=$[$N+$DIR]
241        done
242        INSTALL_READY="yes"
243        register_vars "INSTALL_READY"
244        return 0
245}
246
247function check_param
248{
249        TEMP=$(eval echo \$$1"_ALLOWED")
250        if [ -n "$TEMP" ]; then
251                if ! stringinstring "$2|" "$TEMP|"; then
252                        DEFAULT_TEMP=$(eval echo \$$1"_DEFAULT")
253                        msgbox $"Error: Unknown value $2 for $1\nSetting to default value ($DEFAULT_TEMP)." 10 60
254                        export "$1"="$DEFAULT_TEMP"
255                        logit $"Error: Unknown value $2 for $1\nSetting to default value ($DEFAULT_TEMP)."
256                fi
257        fi
258
259        TEMP=$(eval echo \$$1"_CHECKIT")
260        if [ -n "$TEMP" ]; then
261                if ! $TEMP; then
262                        msgbox $"Error: Check failed for $1 ($2)\nThe configuration module will now be started." 10 60
263                        export "$1"=""
264                        logit $"Error: Check failed for $1 ($2)\nThe configuration module will now be started."
265
266                        RC=1
267                        while [ "$RC" -eq "1" ]; do
268                                ${TEMP/_check/} 1
269                                RC=$?
270                        done
271                fi
272        fi
273        return 0
274}
275
276function load_config
277{
278        T1=$"Loading Parsix GNU/Linux configuration"
279        if [ -z "$1" ]; then
280                wizard $"Here you can input a filename to load an existing configuration" --inputbox $"Input the configuration filename to be loaded" 10 60 "$CONFIG_USER"
281                [ $? -ne 0 ] && return 1
282                CONFIG_USER=$(cat $TMP)
283                if [ ! -r "$CONFIG_USER" ]; then
284                        msgbox $"File $CONFIG_USER could not be found. The loading of the configuration will be aborted." 10 60
285                        return 1
286                fi
287                set -- "$CONFIG_USER"
288        fi
289        logit "$T1 $1"
290        source $1
291
292        for i in $MODULES_LOAD; do
293                "module_${i}_defaults"
294        done
295 
296        for i in $REGISTERED; do
297                #echo "$i=${!i}"
298                #echo check_param "$i" "${!i}"
299                check_param "$i" "${!i}"
300        done
301}
302
303function save_config
304{
305        T1=$"Parsix GNU/Linux installation"
306        BT=$"Saving Parsix GNU/Linux configuration"
307        if [ -z "$1" ]; then
308                wizard $"Here you can input a filename to save the configuration" --inputbox $"Input a filename for the configuration" 10 60 "$CONFIG_USER"
309                [ $? -ne 0 ] && return 1
310                CONFIG_USER=$(cat $TMP)
311                [ -z "$CONFIG_USER" ] && return 1
312                if [ -r "$CONFIG_USER" ]; then
313                        wizard $"If you click yes, the file will be overwritten, otherwise this program will abort" --defaultno --yesno $"Do you really want to overwrite $CONFIG_USER?" 10 60
314                        [ $? -ne 0 ] && return 1
315                fi
316                set -- "$CONFIG_USER"
317        fi
318        logit "$T1 $1"
319        echo "REGISTERED='$REGISTERED'" > $1
320        for i in $REGISTERED; do
321                [ "${!i}" = "configured" ] && echo "" >> $1
322                TEMP=$(eval echo \$$i"_COMMENT")
323                [ -n "$TEMP" ] && echo "# $TEMP" >> $1
324                TEMP=$(eval echo \$$i"_ALLOWED")
325                [ -n "$TEMP" ] && echo "#" $"Possible are:" $TEMP >> $1
326                TEMP=$(eval echo \$$i"_CHECKIT")
327                [ -n "$TEMP" ] && echo "#" $"This value will be checked by function" $TEMP >> $1
328                TEMP=$(eval echo \$$i"_DEFAULT")
329                [ -n "$TEMP" ] && echo "#" $"Default value is:" $TEMP >> $1
330
331                echo "$i='${!i}'" >> $1
332        done
333}
334
335function show_install_options
336{
337        echo > $TMP
338        I=0
339        # System needs an extra sausage (german limerick ;-) )
340        module_system_showinfo >> $TMP
341
342        while [ "$I" -lt "$NUM_MODULES" ]; do
343                "module_${MODULES[$I]}_showinfo"
344                I=$[I+1]
345        done >> $TMP
346        echo "" >> $TMP
347        echo $"Several of this options can only be changed in the Configuration file $CONFIG_FILE." >> $TMP
348        echo $"The Installation will now be started. The author and parsix.org give no warranty against any damage caused by this program." >> $TMP
349        echo "" >> $TMP
350        echo $"Do you want to proceed with these parameters?" >> $TMP
351        DISP_TEXT=$(cat $TMP)
352        wizard $"Make sure you agree to all parameters, if so proceed with the installation." --yesno "$DISP_TEXT" 35 60
353}
354
355function old_installer
356{
357        if [ "$SYSTEM_TYPE" = "knoppix" ]; then
358                system_type_knoppix
359                return 0
360        fi
361       
362        system_type_beginner
363       
364        [ "$SYSTEM_TYPE" = "beginner" ] && return 0
365
366        update_status $"Building udev and hotplug subsystem..."
367
368        [ "$INSTALL_KANO" == "yes" ] && [ ! -e /etc/init.d/udev ] && cp -af $TEMPLATE_PATH/etc/hotplug/usb/usb-storage $TARGET_MNT_POINT/etc/hotplug/usb/
369        sleep 2
370
371        system_services
372
373        return 0
374}
375
376function do_install
377{
378        echo ""
379        INSTALL_LIST="module_hd_doaction module_swap_doaction update_fstab old_installer add_bootmanager final_cleanup :"
380        INSTALL_LIST_NUM=$[6-1]
381        N=0;
382        for i in $INSTALL_LIST; do
383                echo $[$N*100/$INSTALL_LIST_NUM]
384                "${i}"
385                [ $? -ne 0 ] && return 1
386                N=$[$N+1]
387        done
388        return 0
389}
390
391function start_install
392{
393        if [ -z "$INSTALL_READY" ]; then
394                create_config
395                [ $? -ne 0 ] && return 1
396        fi
397        T1=$"Parsix GNU/Linux installation"
398        BT=$"Parsix GNU/Linux installation"
399
400        if [ -z "$INSTALL_READY" ]; then
401                msgbox $"Error: No complete Configuration found" 10 60
402                return 1
403        fi
404        show_install_options
405        [ $? -ne 0 ] && return 1
406        touch $TMPDIR/errors
407        save_config $CONFIG_FILE
408
409        # Reassigning Titles after saving configuration
410        T1=$"Parsix GNU/Linux installation"
411        BT=$"Parsix GNU/Linux installation"
412       
413        do_install | $DIALOG --backtitle "$BT" --title "$T1" --gauge $"Installing" 10 60
414        RC=$?
415        MODULE_ERROR=$(<$TMPDIR/errors)
416        if [ -n "$MODULE_ERROR" ]; then
417                msgbox "Error: $MODULE_ERROR" 10 60
418                return 1
419        fi
420        [ $RC -ne "0" ] && return 1
421
422        #
423        # FLOPPY DISK!
424        #
425
426        if [ "$BOOT_DISK" = "yes" ]; then
427                $DIALOG --backtitle "$BT" --title $"Creating floppy disk" --defaultno --yesno $"Please insert now an empty floppy disk into your floppydrive.\nWarning: All data on it will be lost. If you don't want to create a disk you can choose No." 0 0
428                if [ $? -eq 0 ]; then
429                        make_floppy
430                fi
431        fi
432
433        # /var/tmp workaround
434        chmod 777 $TARGET_MNT_POINT/var/tmp
435
436         for i in $HD_MAP; do
437                point=$(echo $i | cut -d":" -f2)
438                umount $TARGET_MNT_POINT$point
439        done
440                     
441        # Just to be sure :-)
442        #umount $TARGET_MNT_POINT/proc
443        umount $TARGET_MNT_POINT
444        # Success Message and end installer
445        #T1=$"Success!"
446        T1=$ST
447 
448        msgbox $"Parsix GNU/Linux was successfully installed to hard disk." 10 55
449        logit $"Parsix GNU/Linux was successfully installed to hard disk."
450
451        #FIXME 
452        #$DIALOG --backtitle "$T1" --title "$T1" --defaultno --yesno $"Would you like to reboot now?" 10 50
453        #if [ $? -eq 0 ]; then
454        #       sudo reboot
455        #fi
456
457        exit 0
458}
459
460function start_update
461{
462        ROOT_PARTS=$(find_root_partitions $HD_CHOICE)
463
464        T1=$"Parsix GNU/Linux installation"
465        BT=$"Parsix GNU/Linux update installation"
466         
467        radiolist $"Here you must choose one of the available partitions\n to update an existing Parsix GNU/Linux installation." $"Choose the partition to update your existing Parsix GNU/Linux" $ROOT_PARTS
468        [ $? -eq 1 ] && return 1
469         
470        HD_UPDATE_CHOICE="$(cat $TMP)"
471
472        # UNMOUNT DEVICE FIRST
473        umount $HD_UPDATE_CHOICE
474
475        register_vars "HD_UPDATE_CHOICE"
476
477        $DIALOG --backtitle "$BT" --title "Parsix GNU/Linux installation" --defaultno --yesno $"The next step in the update installation mode is to delete everything on the root partition except some files.\nThese files will be backed-up during the update process and will put back after the installation of the new Parsix GNU/Linux version. \nIf anything goes wrong here your data can be lost. We really recommend to backup your data now.\n\nAre you sure that want to continue?" 0 0
478
479        if [ ! $? -eq 0 ]; then
480            msgbox $"Update process aborted." 10 50
481            exit 0
482        fi
483       
484        do_update | $DIALOG --backtitle "$BT" --title "$T1" --gauge $"Starting update installation tasks..." 10 60
485        RC=$?
486        [ $RC -ne "0" ] && return 1
487
488        cd "$ROOT_MP"
489
490        # Backing up xorg.conf
491        cp ./etc/X11/xorg.conf ./etc/X11/xorg.conf.pi.backup
492        cp /etc/X11/XF86Config-4 ./etc/X11/xorg.conf
493
494        $DIALOG --backtitle "$BT" --title $"X.Org Configuration Restore" --defaultno --yesno $"Would you like to restore your original xorg.conf configuration file?\nThis will keep your graphical settings." 0 0
495        if [ $? -eq 0 ]; then
496             mv ./etc/X11/xorg.conf.pi.backup ./etc/X11/xorg.conf
497        fi
498
499        # Getting default desktop
500        if [ -f /etc/sysconfig/desktop ]; then
501             source /etc/sysconfig/desktop
502        fi
503
504        case "$DESKTOP" in
505             gnome)
506                $DIALOG --backtitle "$BT" --title $"GNOME Configuration Reset" --defaultno --yesno $"Would you like to reset your GNOME configuration to defaults?\nAnswer No to keep your GNOME configuration as is." 0 0
507                if [ $? -eq 0 ]; then
508                        for x in ./home/*
509                        do
510                                TMPUSER="$(basename $x)"
511                                COUNT="$(grep -c $TMPUSER ./etc/passwd)"
512                                if [ $COUNT -ne 0 ]; then
513                                        cp -r /etc/skel/.gnom* $x/
514                                        cp -r /etc/skel/.gcon* $x/
515                                        cp -r /etc/skel/.config/ $x/
516                                        chown -R $TMPUSER.$TMPUSER $x/.gnom*
517                                        chown -R $TMPUSER.$TMPUSER $x/.gcon*
518                                        chown -R $TMPUSER.$TMPUSER $x/.config
519                                fi
520                        done
521                else
522                        # RESET G-P-M Settings anyway
523                        for x in ./home/*
524                        do
525                                TMPUSER="$(basename $x)"
526                                COUNT="$(grep -c $TMPUSER ./etc/passwd)"
527                                if [ $COUNT -ne 0 ]; then
528                                        cp /etc/skel/.gconf/apps/gnome-power-manager/%gconf.xml $x/.gconf/apps/gnome-power-manager/
529                                        cp -r /etc/skel/.config/ $x/
530                                        chown -R $TMPUSER.$TMPUSER $x/.gcon*
531                                        chown -R $TMPUSER.$TMPUSER $x/.config
532                                fi
533                        done
534                fi
535             ;;
536        esac
537
538        cd "$BACKDIR"
539        [ $MOUNTED_BY_SCRIPT ] && umount "$ROOT_DEV" 2>/dev/null
540
541
542        #################### Finished ;-) ####################
543        if [ -f /tmp/p-i-updated ]; then
544                msgbox $"Parsix GNU/Linux is now updated." 10 50
545                logit $"Parsix GNU/Linux is now updated."
546
547                #FIXME         
548                #$DIALOG --backtitle "$BT" --title "$T1" --defaultno --yesno $"Would you like to reboot now?" 10 50
549                #if [ $? -eq 0 ]; then
550                #       sudo reboot
551                #fi
552        fi
553        exit 0
554}
555
556function menu_main
557{
558  T1=$"Parsix GNU/Linux installation"
559  BT=$"Installation Main Menu"
560  do_menu $"Thats the main menu\nChoose your wanted action" $"Choose an action" \
561  "create_config" $"Configure Installation" $"Create a new configuration" \
562  "start_install" $"Start installation" $"Start the installation" \
563  "start_update" $"Update installation" $"Update existing installation" \
564  "action-part-later" $"Partition" $"Partition the hard disk" \
565  "load_config" $"Load config" $"Load an existing configuration" \
566  "save_config" $"Save config" $"Save the configuration" \
567  "exit_proc" $"Quit" $"Quit the program"
568}
569
570function main()
571{
572logit $"parsix-installer started"
573msgbox $"This program installs Parsix GNU/Linux to hard disk or updates existing Parsix GNU/Linux installations.\n\nNote that this program is still under development. Please report bugs to http://bugs.parsix.org" 12 60
574rebuildfstab -r
575while ! check_partition_ok;
576do
577  msgbox $"The installer detected that the installation requierements are not fullfilled yet.\
578\n\nPlease make sure that you have an free partition with at least $[ROOT_MIN/(1024*1024)] GB to install Parsix GNU/Linux on. \
579Also we need a swap partition with at least $[SWAP_MIN/1024] MB, if you don't have 512 MB Memory or more.\
580\n\nIn the following menu, you can start some tools to partition your harddrive.\
581\nIf you really really know what you are doing start with: IGNORE_CHECK=1 sudo parsix-installer to avoid the menu." 21 60
582  menu_part
583done
584logit $"Partition check succeeded"
585[ -f "$CONFIG_FILE" ] && load_config $CONFIG_FILE # auto load of configuration
586
587while true; do
588        menu_main
589done
590}
591
592#
593# UNTESTED-Please DO!
594# Added non-interactive mode, FF 29.09.2003
595#
596
597function ni-main
598{
599        logit $"parsix-installer started"
600 
601        rebuildfstab -r
602        logit $"Partition check succeeded"
603 
604        if [ ! -f "$CONFIG_FILE" ]; then
605                echo $"Config file $CONFIG_FILE could not be found. This is necessary for non-interactive mode."
606                return
607        fi
608        load_config $CONFIG_FILE # auto load of configuration
609 
610        touch $TMPDIR/errors
611        T1=$"Parsix GNU/Linux installation"
612        do_install | $DIALOG --backtitle "$BT" --title "$T1" --gauge $"Installing" 10 60
613        RC=$?
614        MODULE_ERROR=$(<$TMPDIR/errors)
615 
616        if [ -n "$MODULE_ERROR" ]; then
617                msgbox "Error: $MODULE_ERROR" 10 60
618                return 1
619        fi
620
621        for i in $HD_MAP; do
622                point=$(echo $i | cut -d":" -f2)
623                umount $TARGET_MNT_POINT$point
624        done
625                     
626        # Just to be sure :-)
627        #umount $TARGET_MNT_POINT/proc
628        umount $TARGET_MNT_POINT
629        # Success Message and end installer
630        logit $"Parsix GNU/Linux was successfully installed to hard disk."
631        exit 0
632}
633
634do_update()
635{
636
637EXCLUDE_LIST="/etc/fstab
638/etc/group
639/etc/passwd
640/etc/shadow
641/etc/gshadow
642/etc/hostname
643/etc/mailname
644/etc/exports
645/etc/ndiswrapper
646/etc/hosts
647/etc/ssh
648/etc/iftab
649/etc/resolv.conf
650/etc/dhcpc/resolv.conf
651/etc/ppp
652/etc/chatscripts
653/etc/samba
654/etc/gpm.conf
655/etc/network/interfaces
656/etc/network/wep.*
657/etc/wpa_supplicant.conf
658/etc/cups
659/usr/src
660/usr/src/fglrx*
661/usr/src/NVIDIA*
662/usr/src/linux-*tar.bz2
663/etc/X11/xorg.conf
664/etc/default/915resolution
665/home
666/root
667/srv
668/var"
669
670
671INCLUDE_LIST="/etc/init.d
672/etc/rc?.d
673/etc/modprobe.d
674/etc/modules*
675/etc/modutils
676/etc/network/options
677/var/log
678/var/tmp
679/var/lib/alsa/asound.state
680/var/lib
681/var/run
682/var/lock
683/var/spool
684/var/cache/apt/*.bin
685/var/cache/apt-show-versions
686/var/cache/apt-build
687/var/cache/man
688/var/cache/debconf
689/var/cache/samba
690/var/cache/apache
691/var/cache/chrootkit
692/var/cache/locate"
693
694MOUNTPOINTS_TO_OVERWRITE="/bin
695/dev
696/etc
697/lib
698/sbin
699/usr
700/boot
701/root
702/home
703/var"
704
705# override tool behaviour through distro-defaults
706[ -r /etc/default/distro ] && source /etc/default/distro
707[ "$FLL_MOUNTPOINT" ] || FLL_MOUNTPOINT="/PARSIX"
708[ "$FLL_LIVE_USER" ] || FLL_LIVE_USER="parsix"
709
710MEDIA_DIR="/media"
711
712ROOT_DEV="$HD_UPDATE_CHOICE"
713ROOT_MP="$MEDIA_DIR/$(basename "$HD_UPDATE_CHOICE")"
714
715register_vars "ROOT_DEV"
716register_vars "ROOT_MP"
717
718#################### Remount Root-Partition r/w ####################
719if ! ( mount | egrep "^$ROOT_DEV" 2>/dev/null >/dev/null ); then
720mount "$ROOT_DEV" 2>/dev/null
721MOUNTED_BY_SCRIPT=1
722
723register_vars "MOUNTED_BY_SCRIPT"
724
725fi
726mount -o remount,rw "$ROOT_DEV" 2>/dev/null >/dev/null
727BACKDIR="$(pwd)"
728
729register_vars "BACKDIR"
730
731cd "$ROOT_MP"
732
733T1=$"Parsix GNU/Linux installation"
734BT=$"Parsix GNU/Linux update installation"
735#################### Check for Parsix ####################
736if [ ! -e "./etc/parsix-version" ]; then
737    msgbox $"Error: No Parsix GNU/Linux Installation found on $ROOT_MP ($ROOT_DEV)" 10 60
738    cd "$BACKDIR"
739    [ $MOUNTED_BY_SCRIPT ] && umount "$ROOT_DEV"
740    return 1
741else
742    if [ ! -e "./etc/parsix-version" ]; then
743            update_status $"Upgrading Old Parsix GNU/Linux to $(cat "/etc/parsix-version")..."
744            echo 0
745    else
746            update_status $"Upgrading $(cat "./etc/parsix-version") to $(cat "/etc/parsix-version")..."
747            echo 0
748    fi         
749fi
750
751#################### First check if all MP's are unmounted ####################
752MP_LIST="$(cat "./etc/fstab" | egrep -v "^([\s]*[^/].*|)$" | awk '{print $1 ":" $2}' | egrep -v "^(/|[^/].*)$")"
753for i in $MP_LIST
754do
755    part=$(echo $i | cut -d":" -f1)
756    point=$(echo $i | cut -d":" -f2)
757    if grep -q "$(basename "$part")" /proc/partitions; then
758       if ( echo "$MOUNTPOINTS_TO_OVERWRITE" | egrep "^$point$" 2>/dev/null >/dev/null); then
759           if grep -q ^$part /proc/mounts; then
760                # Auto unmount / no message
761                umount $part
762           fi
763       fi
764    fi
765done
766
767# Recheck the mount points
768for i in $MP_LIST
769do
770    part=$(echo $i | cut -d":" -f1)
771    point=$(echo $i | cut -d":" -f2)
772    if grep -q "$(basename "$part")" /proc/partitions; then
773       if ( echo "$MOUNTPOINTS_TO_OVERWRITE" | egrep "^$point$" 2>/dev/null >/dev/null); then
774           if grep -q ^$part /proc/mounts; then
775                msgbox $"Error: Partition $part ($point) is already mounted!" 10 60
776                cd "$BACKDIR"
777                [ $MOUNTED_BY_SCRIPT ] && umount "$ROOT_DEV"
778                return 1
779           fi
780       fi
781    fi
782done
783
784#################### Add Mountpoints to rescue list ####################
785MP_LIST="$(cat "./etc/fstab" | egrep -v "^([\s]*[^/].*|)$" | awk '{print $1 ":" $2}' | egrep -v "^(/|[^/].*)$")"
786for i in $MP_LIST
787do
788    part=$(echo $i | cut -d":" -f1)
789    point=$(echo $i | cut -d":" -f2)
790    if grep -q "$(basename "$part")" /proc/partitions; then
791       if ( echo "$MOUNTPOINTS_TO_OVERWRITE" | egrep "^$point$" 2>/dev/null >/dev/null); then
792           mkdir -p ".$point"
793           mount "$part" ".$point" 2> /dev/null
794       else
795           EXCLUDE_LIST="$EXCLUDE_LIST
796$point"
797       fi
798       CONFIG_HDMAP="$CONFIG_HDMAP
799$part:$point"
800    fi
801done
802
803#################### Create a .knofig-File for the installer ####################
804ROOT_FSTYPE="$(egrep -v "^([\s]*[^/].*|)$" ./etc/fstab | awk '{if($2=="/"){print $3}}')"
805if ! grep -q "x:1000:1000:" ./etc/passwd; then
806    msgbox $"Could not detect default user with id 1000. Update not possible!" 10 60
807    return 1
808fi
809CONFIG_NAME="$(egrep "x:1000:1000:" ./etc/passwd | cut -d: -f5)"
810CONFIG_USER="$(egrep "x:1000:1000:" ./etc/passwd | cut -d: -f1)"
811CONFIG_HOST="$(cat ./etc/hostname)"
812CONFIG_HDMAP="$(echo "$CONFIG_HDMAP" | egrep  "^/dev/[hs]d..:/." | egrep -v "/dev/[hs]d..:$MEDIA_DIR/[hs]d..")"
813[ "$BOOT_LOADER" ] && CONFIG_BOOT_LOADER="$BOOT_LOADER" || CONFIG_BOOT_LOADER="grub"
814[ "$BOOT_WHERE" ] && CONFIG_BOOT_WHERE="$BOOT_WHERE" || CONFIG_BOOT_WHERE="mbr"
815
816cat <<END >$HOME/.knofig
817REGISTERED=' SYSTEM_MODULE SYSTEM_TYPE HD_MODULE HD_FORMAT HD_FSTYPE HD_CHOICE HD_MAP HD_IGNORECHECK SWAP_MODULE SWAP_AUTODETECT NAME_MODULE NAME_NAME USER_MODULE USER_NAME USERPASS_MODULE USERPASS_CRYPT ROOTPASS_MODULE ROOTPASS_CRYPT HOST_MODULE HOST_NAME SERVICES_MODULE SERVICES_START BOOT_MODULE BOOT_LOADER BOOT_DISK BOOT_WHERE INSTALL_READY'
818
819SYSTEM_MODULE='configured'
820# Determines if the system is a debian-derivate, a copy from CD or a nice mix of both
821# Possible are: knoppix|debian
822# Default value is: debian
823SYSTEM_TYPE='debian'
824
825HD_MODULE='configured'
826# Determines if the HD should be formatted. (mkfs.*)
827# Possible are: yes|no
828HD_FORMAT='no'
829# Sets the Filesystem type.
830# Possible are: ext3|ext2|reiserfs|reiser4|xfs|jfs
831HD_FSTYPE='$ROOT_FSTYPE'
832# Here the Parsix-System will be installed
833# This value will be checked by function module_hd_check
834HD_CHOICE='$ROOT_DEV'
835# Here you can give additional mappings. (Experimental) You need to have the partitions formatted yourself and give the correct mappings like: "/dev/hda4:/boot /dev/hda5:/var /dev/hda6:/tmp"
836HD_MAP='$CONFIG_HDMAP'
837# If set to yes, the program will NOT check if there is enough space to install knoppix on the selected partition(s). Use at your own risk! Useful for example with HD_MAP if you only have a small root partition.
838# Possible are: yes|no
839HD_IGNORECHECK='yes'
840
841SWAP_MODULE='configured'
842# If set to yes, the swap partitions will be autodetected.
843# Possible are: yes|no
844# Default value is: yes
845SWAP_AUTODETECT='yes'
846
847NAME_MODULE='configured'
848NAME_NAME='$CONFIG_NAME'
849
850USER_MODULE='configured'
851USER_NAME='$CONFIG_USER'
852
853USERPASS_MODULE='configured'
854USERPASS_CRYPT='------------'
855
856ROOTPASS_MODULE='configured'
857ROOTPASS_CRYPT='------------'
858
859HOST_MODULE='configured'
860HOST_NAME='$CONFIG_HOST'
861
862SERVICES_MODULE='configured'
863# Possible services are for now: kdm cupsys smail ssh samba
864# Default value is: cupsys
865SERVICES_START='cupsys'
866
867BOOT_MODULE='configured'
868# Chooses the Boot-Loader
869# Possible are: grub
870# Default value is: grub
871BOOT_LOADER='$CONFIG_BOOT_LOADER'
872# If set to 'yes' a boot disk will be created!
873# Possible are: yes|no
874BOOT_DISK='no'
875# Where the Boot-Loader will be installed
876# Possible are: mbr|partition
877# Default value is: mbr
878BOOT_WHERE='$CONFIG_BOOT_WHERE'
879INSTALL_READY='yes'
880END
881
882echo 10
883
884#################### Check knofig ####################
885if which kanotix-check-knofig >/dev/null; then
886    kanotix-check-knofig $HOME/.knofig
887    ERROR=$?
888    if [ $ERROR -ne 0 ]; then
889        $DIALOG --backtitle "$BT" --title $"Update Warning" --defaultno --yesno $"ERROR: parsix-check-knofig returned $ERROR as error code!\nDo you want to force the update?" 0 0
890        if [ ! $? -eq 0 ]; then
891                msgbox $"Update process aborted." 10 50
892                exit 0
893        fi
894    fi
895fi
896
897#################### Starting Timer ####################
898START_TIME=$(date +%s)
899TMP_TIME="$(mktemp -t timediff.XXXXXX)"
900
901#################################################################################################################
902CUR_PACKAGES=$(dpkg -l|awk '/^ii/{print $2}')
903NEW_KERNEL=$(uname -r)
904CUR_PACKAGES=$(echo $CUR_PACKAGES|tr ' ' '\n'|grep -v $NEW_KERNEL)
905OLD_PACKAGES=$(chroot . dpkg -l|awk '/^ii/{print $2}')
906cd ./boot
907for v in vmlinuz-*; do
908    KERNEL=$(echo $v|sed s/vmlinuz-//)
909    OLD_PACKAGES=$(echo $OLD_PACKAGES|tr ' ' '\n'|grep -v $KERNEL)
910done
911for PACKAGE in $CUR_PACKAGES
912do
913    OLD_PACKAGES=$(echo $OLD_PACKAGES|tr ' ' '\n'|grep -v -e "^$PACKAGE$")
914done
915cd ..
916echo $OLD_PACKAGES|tr ' ' '\n' > ./root/diffpackages-$(date +%Y%m%d-%H%M).txt
917#update_status $"Saved old and new package Diff-List in /root/diffpackages-$(date +%Y%m%d-%H%M).txt"
918
919#################### Update Groups and Users in ./etc/groups, ./etc/passwd and ./etc/shadow ####################
920
921DIFF_GROUPS="$( ( cut -d: -f1 ./etc/group; cut -d: -f1 /etc/group ) | sort | uniq -u | grep -v -e $FLL_LIVE_USER -e $CONFIG_USER)"
922
923for GROUP in $DIFF_GROUPS
924do
925        GROUP_LINE="$(false)";
926        if GROUP_LINE="$(egrep "^$GROUP:" /etc/group)"; then
927                #update_status $"Adding group '$GROUP' to /etc/group..."
928                echo "$GROUP_LINE" >> ./etc/group
929        fi
930done
931
932DIFF_USERS="$( ( cut -d: -f1 ./etc/passwd; cut -d: -f1 /etc/passwd) | sort | uniq -u | grep -v -e $FLL_LIVE_USER -e $CONFIG_USER)"
933
934for USER in $DIFF_USERS
935do
936        USER_LINE="$(false)";
937        if USER_LINE="$(egrep "^$USER:" /etc/passwd)"; then
938                #update_status $"Adding user '$USER' to /etc/passwd..."
939                echo "$USER_LINE" >> ./etc/passwd
940                if ! egrep -q "^$USER:" ./etc/shadow; then
941                  SHADOW_LINE="$(egrep "^$USER:" /etc/shadow)"
942                  if [ "$SHADOW_LINE" ]; then
943                    #update_status $"Adding user '$USER' to /etc/shadow..."
944                    echo "$SHADOW_LINE" >> ./etc/shadow
945                  fi
946                fi
947        fi
948done
949
950DIFF_GROUPMEMBERS="$( ( grep $FLL_LIVE_USER /etc/group | cut -d: -f1; grep $CONFIG_USER ./etc/group | cut -d: -f1 ) | sort | uniq -u | grep -v -e $FLL_LIVE_USER -e $CONFIG_USER )"
951
952for GROUP in $DIFF_GROUPMEMBERS
953do
954        IS_MEMBER="$(false)";
955        if IS_MEMBER="$(egrep "^$GROUP:" ./etc/group | grep -v $CONFIG_USER)"; then
956                #update_status $"Adding '$CONFIG_USER' to group '$GROUP'..."
957                if egrep -q "^$GROUP.*:$" ./etc/group; then
958                  sed -i "s/^$GROUP.*$/\0$CONFIG_USER/g" ./etc/group
959                else
960                  sed -i "s/^$GROUP.*$/\0,$CONFIG_USER/g" ./etc/group
961                fi
962        fi
963done
964
965USERS=$(cut -d: -f4 /etc/group | tr ',' '\n' | sort | uniq | sed '/^$/d' | grep -v -e $FLL_LIVE_USER -e $CONFIG_USER)
966for USER in $USERS
967do
968    DIFF_GROUPMEMBERS="$( ( grep $USER /etc/group | cut -d: -f1; grep $USER ./etc/group | cut -d: -f1 ) | sort | uniq -u )"
969   
970    for GROUP in $DIFF_GROUPMEMBERS
971    do
972            IS_MEMBER="$(false)";
973            if IS_MEMBER="$(egrep "^$GROUP:" ./etc/group | grep -v $USER)"; then
974                    #update_status $"Adding '$USER' to group '$GROUP'..."
975                    if egrep -q "^$GROUP.*:$" ./etc/group; then
976                        sed -i "s/^$GROUP.*$/\0$USER/g" ./etc/group
977                    else
978                        sed -i "s/^$GROUP.*$/\0,$USER/g" ./etc/group
979                    fi
980            fi
981    done
982done
983
984update_status $"Updated Groups and Users."
985echo 20
986sleep 3
987update_status $"Please wait a bit, the files are being deleted now..."
988echo 30
989
990#################### Delete the things that have to be deleted ####################
991
992for WITH in $INCLUDE_LIST
993do
994    rm -r ".$WITH" 2>/dev/null
995done
996
997echo 35
998
999#################### Search for the files to move ####################
1000
1001# Move the things to save into "$MOUNTPOINT/parsix-update"
1002DIRS="$(grep $PWD /proc/mounts | awk '{print $2}' | sort -r)"
1003for DIR in $DIRS
1004do
1005        MOUNTPOINT="${DIR/*$PWD}"
1006        if [ "$MOUNTPOINT" ]; then
1007                [ "$DIRS_ALREADY_SAVED" ] && DIRS_ALREADY_SAVED="$DIRS_ALREADY_SAVED|^$MOUNTPOINT" || DIRS_ALREADY_SAVED="^$MOUNTPOINT"
1008                for THING in $(echo "$EXCLUDE_LIST" | grep ^$MOUNTPOINT)
1009                do
1010                        [ -e "${DIR}/parsix-update" ] || mkdir -p "${DIR}/parsix-update"
1011                        THING=".$THING"
1012                        for THING_P in $THING
1013                        do
1014                                mp=${THING_P:1}
1015                                if [ -d "${PWD}${mp}" ]; then
1016                                        mv ${PWD}${mp}/.* ${PWD}${mp}/* ${DIR}/parsix-update 2>/dev/null
1017                                elif [ -e "${PWD}${mp}" ] || ls "${PWD}${mp}" 2>/dev/null; then
1018                                        SUBDIR="$(dirname "${mp}")"
1019                                        [ -d "${DIR}/parsix-update${SUBDIR/*$MOUNTPOINT}" ] || mkdir -p ${DIR}/parsix-update${SUBDIR/*$MOUNTPOINT}
1020                                        mv ${PWD}${mp} ${DIR}/parsix-update${SUBDIR/*$MOUNTPOINT} 2>/dev/null
1021                                fi
1022                        done
1023                done
1024        fi
1025done
1026
1027echo 40
1028
1029# Move the things to save into "/parsix-update"
1030[ "$DIRS_ALREADY_SAVED" ] && THINGS_TO_SAVE=$(echo "$EXCLUDE_LIST" | grep -v -E $DIRS_ALREADY_SAVED) || THINGS_TO_SAVE="$EXCLUDE_LIST"
1031for THING in $THINGS_TO_SAVE
1032do
1033        [ -e "parsix-update" ] || mkdir "parsix-update"
1034        THING=".$THING"
1035        for THING_P in $THING
1036        do
1037                if [ -e $THING_P ] || ls "$THING_P" 2>/dev/null; then
1038                        [ -d "$(dirname "./parsix-update${THING_P:1}")" ] || mkdir -p "$(dirname "./parsix-update${THING_P:1}")"
1039                        mv $THING_P ./parsix-update${THING_P:1} 2>/dev/null
1040                fi
1041        done
1042done
1043
1044echo 45
1045
1046# Delete everything exept "parsix-update"-Folders
1047DIRS="$(grep $PWD /proc/mounts | awk '{print $2}' | sort -r)"
1048for DIR in $DIRS
1049do
1050        for FOLDER in $DIR/*
1051        do
1052                if [ "$(basename $FOLDER)" != "parsix-update" ]; then
1053                        if ! grep $PWD /proc/mounts | awk '{print $2}' | grep -q "$FOLDER"; then
1054                                rm -rf $FOLDER
1055                        fi
1056                fi
1057        done
1058done
1059
1060#################### Everything is deleted now. ####################
1061update_status $"Everything is deleted, now starting the installation..."
1062echo 60
1063
1064logit $"parsix-installer started"
1065 
1066rebuildfstab -r
1067logit $"Partition check succeeded"
1068 
1069if [ ! -f "$CONFIG_FILE" ]; then
1070        echo $"Config file $CONFIG_FILE could not be found. This is necessary for non-interactive mode."
1071        return
1072fi
1073load_config $CONFIG_FILE # auto load of configuration
1074 
1075touch $TMPDIR/errors
1076
1077echo 0
1078
1079T1=$"Parsix GNU/Linux installation"
1080do_install
1081RC=$?
1082MODULE_ERROR=$(<$TMPDIR/errors)
1083 
1084if [ -n "$MODULE_ERROR" ]; then
1085        msgbox "Error: $MODULE_ERROR" 10 60
1086        return 1
1087fi
1088for i in $HD_MAP; do
1089        point=$(echo $i | cut -d":" -f2)
1090        umount $TARGET_MNT_POINT$point
1091done
1092                     
1093# Just to be sure :-)
1094#umount $TARGET_MNT_POINT/proc
1095umount $TARGET_MNT_POINT
1096#################### Start the installer ####################
1097
1098if [ $? -ne 0 ]; then
1099    msgbox $"Parsix-Installer failed.\nYour data should be saved at $ROOT_MP/parsix-update. If it isn't there... "
1100    exit 0
1101fi
1102echo 0
1103update_status $"Update installation has finished.\nRestoring backup and doing final tasks..."
1104sleep 3
1105echo 25
1106
1107#################### Put the backup back ####################
1108if ! ( mount | egrep "^$ROOT_DEV" 2>/dev/null >/dev/null ); then
1109    mount "$ROOT_DEV" 2>/dev/null
1110    MOUNTED_BY_SCRIPT=1
1111fi
1112mount -o remount,rw "$ROOT_DEV" 2>/dev/null >/dev/null
1113cd "$ROOT_MP"
1114DIRS="$(grep $PWD /proc/mounts | awk '{print $2}' | sort -r)"
1115ROOTDIR="$PWD"
1116echo 35
1117for DIR in $DIRS
1118do
1119        MOUNTPOINT="${DIR/*$PWD}"
1120        if [ -d "$DIR/parsix-update" ]; then
1121        cd $DIR/parsix-update
1122        find . -type d -exec sh -c 'mv "{}" ".$(dirname "{}")"' \; 2>/dev/null
1123        find . ! -type d -exec mv '{}' '.{}' \; 2>/dev/null
1124        cd $ROOTDIR
1125        rm -rf $DIR/parsix-update
1126        fi
1127done
1128
1129echo 70
1130
1131#################### Patch some things ####################
1132if [ -x /etc/init.d/udev ]; then
1133    rm -f "./etc/skel/Desktop"/Floppy
1134
1135    for HOME_DIR in ./home/*
1136    do
1137        rm -f "$HOME_DIR/Desktop"/[sh]d[a-z][1-9]
1138        rm -f "$HOME_DIR/Desktop"/[sh]d[a-z][1-9][0-9]
1139        rm -f "$HOME_DIR/Desktop"/CD-ROM\ \[cdrom\]
1140        rm -f "$HOME_DIR/Desktop"/CD-ROM\ \[cdrom[1-9]\]
1141        rm -f "$HOME_DIR/Desktop"/Floppy
1142        rm -rf "$HOME_DIR/Desktop"/Trash
1143
1144        USER_ID="$(egrep "^$(basename "$HOME_DIR"):" ./etc/passwd | cut -d: -f3)"     
1145    done
1146   
1147    # Patch automount of USB-devices
1148    TARGET_MNT_POINT="."
1149    export TARGET_MNT_POINT
1150    . /usr/share/parsix-installer/modules/install/01-fstab.bm
1151    USBDEVS=$(get_usb_devices)
1152    [ -n "$USBDEVS" ] && PERLREGEX="${USBDEVS// /|}" || PERLREGEX=".\*"
1153    perl -pi -e 'if (! m#^/dev/('$PERLREGEX')#) { s#^(/dev/[sh]d.*)noauto(.*)$#${1}auto${2}# }' $TARGET_MNT_POINT/etc/fstab
1154   
1155    FSTAB=./etc/fstab   
1156
1157    F=$(grep -v -e ^$ -e ^'#' -e proc -e usbfs -e sysfs -e tmpfs -e ^/mnt/app -e cdrom -e dvd -e floppy $FSTAB)
1158    {
1159    echo "# /etc/fstab: static file system information."
1160    echo "#"
1161    printf "%-15s %-15s %-7s %-15s %-7s %s\n" "# <file system>" "<mount point>" "<type>" "<options>" "<dump>" "<pass>"
1162   
1163    while read a b c d e f; do
1164    if [[ $b == /mnt/* && $b != /mnt/app/* ]] ; then
1165    b=${b/mnt/media}
1166    [ -d .$b ] || mkdir -p .$b
1167    fi
1168    [[ $c == swap ]] && d=sw
1169    printf "%-15s %-15s %-7s %-15s %-7s %s\n" $a $b $c $d $e $f
1170    done <<<"$F"
1171    for c in $(ls -d /dev/cdrom* 2>/dev/null); do
1172    m=${c#/dev}
1173    [ "$m" == "/cdrom" ] && m="/cdrom0"
1174    [ -d ./media$m ] || mkdir -p ./media$m
1175    printf "%-15s %-15s %-7s %-15s %-7s %s\n" "$c" "/media$m" "udf,iso9660" "user,noauto" "0" "0"
1176    done
1177    for f in $(ls -d /sys/block/fd* 2>/dev/null); do
1178    [ -d ./media/floppy${f#/sys/block/fd} ] || mkdir -p ./media/floppy${f#/sys/block/fd}
1179    printf "%-15s %-15s %-7s %-15s %-7s %s\n" "/dev${f#/sys/block}" "/media/floppy${f#/sys/block/fd}" "auto" "rw,user,noauto" "0" "0"
1180    done
1181    } > ./etc/fstab.new
1182    mv ./etc/fstab ./etc/fstab.old
1183    mv ./etc/fstab.new ./etc/fstab
1184       
1185    DEVLINE=`printf "%-15s %-15s %-7s %-15s %-7s %s\n" "devpts" "/dev/pts" "devpts" "defaults" "0" "0"`
1186
1187    # Being sure that devpts line exists
1188    COUNT="$(grep -c devpts ./etc/fstab)"
1189
1190    if [ $COUNT -ne 1 ]; then
1191        perl -pi -e "s|^# <file (.*)|# <file \1\n$DEVLINE|g" ./etc/fstab
1192    fi
1193
1194    # Ensure that there is no proc and usbfs lines
1195    perl -pi -e "s|^proc(.*)||" ./etc/fstab
1196    perl -pi -e "s|^usbfs(.*)||" ./etc/fstab
1197    sed -ie '/^$/d' ./etc/fstab
1198fi
1199
1200echo 85
1201
1202# Patching /mnt to /media
1203FILES_TO_PATCH_MNT_MEDIA="./etc/exports
1204./etc/samba/smb.conf"
1205for FILE_TO_PATCH in $FILES_TO_PATCH_MNT_MEDIA
1206do
1207   if [ -e "$FILE_TO_PATCH" ]; then
1208      perl -pi -e 's|/mnt|/media|g' "$FILE_TO_PATCH"
1209   fi
1210done
1211
1212echo 100
1213
1214#update finish flag
1215touch /tmp/p-i-updated
1216
1217sleep 2
1218
1219return 0
1220}
1221
1222function format_timediff()
1223{
1224        SEK_DIFF=$1
1225        OUTPUT="$[SEK_DIFF%60]s"
1226        if [ $SEK_DIFF -gt 60 ]; then
1227                MINUTES=$[SEK_DIFF/60]
1228                OUTPUT="$[MINUTES%60]m$OUTPUT"
1229                if [ $MINUTES -gt 60 ]; then
1230                        HOURS=$[MINUTES/60]
1231                        OUTPUT="${HOURS}h$OUTPUT"
1232                fi
1233        fi
1234        echo $OUTPUT
1235}
1236
1237function get_time()
1238{
1239        LAST_TIME=$(<$TMP_TIME)
1240        NOW_TIME=$(date +%s)
1241        ALL_DIFF=$[NOW_TIME-START_TIME]
1242        LAST_DIFF=$[NOW_TIME-LAST_TIME]
1243        LAST_TIME=$NOW_TIME
1244        echo $LAST_TIME > "$TMP_TIME"
1245        echo -n "(+$(format_timediff $LAST_DIFF)/($(format_timediff $ALL_DIFF)):"
1246}
1247
1248if [ "$1" = "--non-interactive" ]; then
1249        ni-main
1250        exit 1 # something did go wrong
1251fi
1252
1253if [ $UID -eq 0 ]; then
1254         main
1255else
1256        echo $"root permission needed."
1257fi
1258
Note: See TracBrowser for help on using the repository browser.