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