diff options
Diffstat (limited to 'rescue/Flash/scripts')
-rwxr-xr-x | rescue/Flash/scripts/backup_systemloop | 106 | ||||
-rwxr-xr-x | rescue/Flash/scripts/clear_systemloop | 89 | ||||
-rw-r--r-- | rescue/Flash/scripts/rescue_common | 205 | ||||
-rwxr-xr-x | rescue/Flash/scripts/reset_rootpass | 99 | ||||
-rwxr-xr-x | rescue/Flash/scripts/reset_userpass | 110 | ||||
-rwxr-xr-x | rescue/Flash/scripts/restore_systemloop | 167 | ||||
-rwxr-xr-x | rescue/Flash/scripts/test_badblocks | 69 | ||||
-rwxr-xr-x | rescue/Flash/scripts/upgrade | 307 | ||||
-rwxr-xr-x | rescue/Flash/scripts/upgrade.merge-users | 52 |
9 files changed, 0 insertions, 1204 deletions
diff --git a/rescue/Flash/scripts/backup_systemloop b/rescue/Flash/scripts/backup_systemloop deleted file mode 100755 index 65c3185e6..000000000 --- a/rescue/Flash/scripts/backup_systemloop +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/bash - -# import functions library -source rescue_common - -tmpdir="/tmp/flash-rescue-root" -rootdir="$tmpdir/pen" - -function prepare() { - - mkdir -p $rootdir - - if ! mount_usbroot $rootdir; then - return 1 - fi - - if [ x"$version" = x"1.0" ]; then - mkdir -p $tmpdir/shared - if ! mount_sharedroot $tmpdir/shared; then - return 1 - fi - fi - - if [ ! -d $dir ]; then - mkdir $dir - fi - - return 0 -} - -function doit() { - - clear - echo - echo -n 'Creating backup file. This can take some time: ' - - bzip2 -c $loop > $target 2> /tmp/rescue-backup.err & - - sleep 2 - - while ps | grep -q bzip2; do - progress - done - - sync - - echo - echo - - errsize=$(ls -la /tmp/rescue-backup.err | cut -d' ' -f5) - if [ $errsize -ne 0 ]; then - echo "Error compressing user files into $target" - return 1 - else - echo 'Backup file created!' - fi - - echo - - return 0 -} - -function cleanup() { - - if [ x"$version" = x"1.0" ]; then - umount $tmpdir/shared > /dev/null 2>&1 - rmdir $tmpdir/shared - fi - - umount $rootdir > /dev/null 2>&1 - rmdir $rootdir $tmpdir 2> /dev/null - - return 0 -} - -clear -trap cleanup SIGINT - -version="" -if ! insert_pendrive; then - exit 1 -fi - -if [ x"$version" = x"1.0" ]; then - dir="$tmpdir/shared/backup" - loop="$rootdir/loopbacks/system.loop" -else - dir="$rootdir/backup" - loop="$rootdir/.loopbacks/system.loop" -fi - -file="backup-$(date +%Y%m%d).bz2" -target="$dir/$file" - -if ! prepare; then - cleanup - exit 1 -fi - -if ! doit; then - cleanup - exit 1 -fi - -cleanup -exit 0 diff --git a/rescue/Flash/scripts/clear_systemloop b/rescue/Flash/scripts/clear_systemloop deleted file mode 100755 index 4152b16bf..000000000 --- a/rescue/Flash/scripts/clear_systemloop +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/bash - -# import functions library -source rescue_common - -tmpdir="/tmp/flash-rescue-root" -rootdir="$tmpdir/pen" - -function prepare() { - - mkdir -p $rootdir - - if ! mount_usbroot $rootdir; then - return 1 - fi - - return 0 -} - -function doit() { - - clear - echo - echo "WARNING!" - echo - echo "Mandriva Flash will be reset to factory defaults!" - echo -n "All user files, customizations and new packages installed " - echo "will be removed." - echo - echo "This process may take a few minutes." - echo - echo -n "Do you want to continue? [N/y] " - read confirm - - if [ x"$confirm" = x"y" -o x"$confirm" = x"Y" ]; then - - if [ ! -f $loop ] || [ x"$version" != x"1.0" ]; then - dd if=/dev/zero of=$loop bs=1000000 count=1000 - fi - - if [ x"$version" = x"1.0" ]; then - /sbin/mkfs.ext2 -q -F $loop - fi - - echo - if [ $? -ne 0 ]; then - echo 'Error resetting device to factory defaults' - return 1 - else - echo 'Mandriva Flash was restored to factory defaults!' - fi - fi - - echo - - return 0 -} - -function cleanup() { - - umount $rootdir > /dev/null 2>&1 - rmdir $rootdir $tmpdir 2> /dev/null -} - -clear -trap cleanup SIGINT - -version="" -if ! insert_pendrive; then - exit 1 -fi - -if [ x"$version" = x"1.0" ]; then - loop="$rootdir/loopbacks/system.loop" -else - loop="$rootdir/.loopbacks/system.loop" -fi - -if ! prepare; then - cleanup - exit 1 -fi - -if ! doit; then - cleanup - exit 1 -fi - -cleanup diff --git a/rescue/Flash/scripts/rescue_common b/rescue/Flash/scripts/rescue_common deleted file mode 100644 index 77435e6da..000000000 --- a/rescue/Flash/scripts/rescue_common +++ /dev/null @@ -1,205 +0,0 @@ -#!/bin/bash - -function detect_version() { - version="" - if has_label Share; then - version="1.0" - elif has_label MDVUSBROOT; then - version="1.05" - elif has_label Mdv_Flash; then - version="2.0" - elif has_label MDV_FLASH; then - version="2.05" - fi - usbroot_device=$_device - source_version_variables - - [ -n "$version" ] -} - -function source_version_variables { - local _version - _version=$1 - [ -z "$_version" ] && _version=$version - if [ "$_version" = "1.0" ]; then - label=MDVUSBROOT - boot_rel="/boot" - loopbacks_rel="/loopbacks" - elif [ "$_version" = "1.05" ]; then - label=MDVUSBROOT - boot_rel="/.boot" - loopbacks_rel="/.loopbacks" - elif [ "$_version" = "2.0" ]; then - label=Mdv_Flash - boot_rel="/.boot" - loopbacks_rel="/.loopbacks" - elif [ "$_version" = "2.05" ]; then - label=MDV_FLASH - boot_rel="/.boot" - loopbacks_rel="/.loopbacks" - fi -} - -function has_label() { - local _label _tmpdir - _label=$1 - - _tmpdir="/tmp/$$" - - mkdir -p $_tmpdir - - nash --force > /dev/null 2>&1 <<EOF -mount -t vfat LABEL=$_label $_tmpdir -EOF - - rc=$? - - _device=`perl -ne 'my @l = split; $l[1] eq "'$_tmpdir'" and print "$l[0]\n"' /proc/mounts` - [ -z "$_device" ] && rc=1 - - umount $_tmpdir 2> /dev/null - rmdir $_tmpdir 2> /dev/null - - return $rc -} - -function check_vendor() { - - # list of supported vendors/models - - # mandriva flash 1.0 (france) - vendors[0]="13fe" - models[0]="1a00" - # mandriva flash 1.0 (brazil) - vendors[1]="0930" - models[1]="653e" - # mandriva flash 4GB (france) - vendors[2]="13fe" - models[2]="1d00" - - rc=1 - - mount -t usbfs none /proc/bus/usb 2> /dev/null - - i=0 - while [ ! -z "${vendors[$i]}" ]; do - - grep "P:" /proc/bus/usb/devices | grep -q \ - "Vendor=${vendors[$i]} ProdID=${models[$i]}" - if [ $? -eq 0 ]; then - rc=0 - break - fi - - let i++ - done - - umount /proc/bus/usb 2> /dev/null - - return $rc -} - -function insert_pendrive() { - - _tmpdir="/tmp/rescue-temp" - mkdir -p $_tmpdir - - modprobe usb-storage > /dev/null 2>&1 - modprobe vfat > /dev/null 2>&1 - - echo - echo -n 'Please insert your Mandriva Flash pen drive and press ENTER when ready: ' - read READY - echo - echo -n 'Detecting pen drive: ' - - for ((i=0; $i <= 15 ; i++)); do - detect_version && nash --force > /dev/null 2>&1 <<EOF -mount -t vfat LABEL=$label $_tmpdir -EOF - if [ $? -ne 0 ]; then - echo -n '.' - sleep 1 - else - echo -n ' found!' - - if ! check_vendor; then - echo - echo "This is not an official Mandriva Flash key!" - echo - fi - - cat /proc/mounts | grep $_tmpdir | cut -d' ' -f1 | \ - sed 's/[0-9]*$//g' > /tmp/rescue-device - umount $_tmpdir - rmdir $_tmpdir 2> /dev/null - - return 0 - fi - done - - rmdir $_tmpdir 2> /dev/null - - echo - echo - echo "Couldn't detect Mandriva Flash pen drive!" - echo - - return 1 -} - -function mount_usbroot() { - - nash --force > /dev/null 2>&1 <<EOF -mount -t vfat LABEL=$label $1 -EOF - if [ $? -ne 0 ]; then - echo "Error mounting device labeled $label" - return 1 - fi - - return 0 -} - -function mount_sharedroot() { - - nash --force > /dev/null 2>&1 <<EOF -mount -t vfat LABEL=Share $1 -EOF - if [ $? -ne 0 ]; then - echo "Error mounting device labeled Share" - return 1 - fi - - return 0 -} - -function progress() { - - echo -ne '\b|' - usleep 100000 - echo -ne '\b/' - usleep 100000 - echo -ne '\b-' - usleep 100000 - echo -ne '\b\\' - usleep 100000 -} - -function lumount() { - local dir=$1 - loop=$(perl -ne '@l = split; if ($l[1] eq "'$dir'") { print $l[0]; exit }' /proc/mounts) - umount $dir - losetup -d $loop -} - -function set_sfs_loop() { - local dir=$1 - sfs_loop_std="$dir$loopbacks_rel/distrib.sqfs" - sfs_loop_lzma="$dir$loopbacks_rel/distrib-lzma.sqfs" - if [ -e $sfs_loop_lzma ]; then - sfs_loop=$sfs_loop_lzma - else - sfs_loop=$sfs_loop_std - fi -} diff --git a/rescue/Flash/scripts/reset_rootpass b/rescue/Flash/scripts/reset_rootpass deleted file mode 100755 index 9fd81155a..000000000 --- a/rescue/Flash/scripts/reset_rootpass +++ /dev/null @@ -1,99 +0,0 @@ -#!/bin/bash - -# import functions library -source rescue_common - -tmpdir="/tmp/flash-rescue-root" -rootdir="$tmpdir/pen" - -function prepare() { - - modprobe unionfs > /dev/null 2>&1 - modprobe sqlzma > /dev/null 2>&1 - modprobe squashfs-lzma > /dev/null 2>&1 - modprobe squashfs > /dev/null 2>&1 - modprobe loop > /dev/null 2>&1 - - mkdir -p $rootdir - mkdir -p $tmpdir/squash - mkdir -p $tmpdir/user - mkdir -p $tmpdir/union - - if ! mount_usbroot $rootdir; then - return 1 - fi - - set_sfs_loop $rootdir - - mount -t squashfs -o loop $sfs_loop $tmpdir/squash > /dev/null 2>&1 - if [ $? -ne 0 ]; then - echo "Error mounting distrib.sqfs" - return 1 - fi - - mount -t ext2 -o loop $sys_loop $tmpdir/user > /dev/null 2>&1 - if [ $? -ne 0 ]; then - echo "Error mounting system.loop" - return 1 - fi - - mount -t unionfs -o dirs=$tmpdir/user=rw:$tmpdir/squash=ro \ - none $tmpdir/union - if [ $? -ne 0 ]; then - echo "Error creating union of distrib.sqfs and system.loop" - return 1 - fi - - chroot $tmpdir/union /etc/init.d/keytable start &> /dev/null - chroot $tmpdir/union /usr/bin/unicode_start - - return 0 -} - -function doit() { - - clear - echo - chroot $tmpdir/union passwd root - echo - echo - - return 0 -} - -function cleanup() { - - chroot $tmpdir/union /usr/bin/unicode_stop - - umount $tmpdir/union > /dev/null 2>&1 - lumount $tmpdir/user > /dev/null 2>&1 - lumount $tmpdir/squash > /dev/null 2>&1 - umount $rootdir > /dev/null 2>&1 - - rmdir $tmpdir/union $tmpdir/user $tmpdir/squash 2> /dev/null - rmdir $rootdir $tmpdir 2> /dev/null -} - -clear -trap cleanup SIGINT - -version="" -if ! insert_pendrive; then - exit 1 -fi - -sys_loop="$rootdir$loopbacks_rel/system.loop" -sfs_loop= # - -if ! prepare; then - cleanup - exit 1 -fi - -if ! doit; then - cleanup - exit 1 -fi - -cleanup -exit 0 diff --git a/rescue/Flash/scripts/reset_userpass b/rescue/Flash/scripts/reset_userpass deleted file mode 100755 index e7c5477eb..000000000 --- a/rescue/Flash/scripts/reset_userpass +++ /dev/null @@ -1,110 +0,0 @@ -#!/bin/bash - -# import functions library -source rescue_common - -tmpdir="/tmp/flash-rescue-root" -rootdir="$tmpdir/pen" - -function prepare() { - - modprobe unionfs > /dev/null 2>&1 - modprobe sqlzma > /dev/null 2>&1 - modprobe squashfs-lzma > /dev/null 2>&1 - modprobe squashfs > /dev/null 2>&1 - modprobe loop > /dev/null 2>&1 - - mkdir -p $rootdir - mkdir -p $tmpdir/squash - mkdir -p $tmpdir/user - mkdir -p $tmpdir/union - - if ! mount_usbroot $rootdir; then - return 1 - fi - - set_sfs_loop $rootdir - - mount -t squashfs -o loop $sfs_loop $tmpdir/squash > /dev/null 2>&1 - if [ $? -ne 0 ]; then - echo "Error mounting distrib.sqfs" - return 1 - fi - - mount -t ext2 -o loop $sys_loop $tmpdir/user > /dev/null 2>&1 - if [ $? -ne 0 ]; then - echo "Error mounting system.loop" - return 1 - fi - - mount -t unionfs -o dirs=$tmpdir/user=rw:$tmpdir/squash=ro \ - none $tmpdir/union > /dev/null 2>&1 - if [ $? -ne 0 ]; then - echo "Error creating union of distrib.sqfs and system.loop" - return 1 - fi - - chroot $tmpdir/union /etc/init.d/keytable start &> /dev/null - chroot $tmpdir/union /usr/bin/unicode_start - - return 0 -} - -function doit() { - - username=$(tail -1 $tmpdir/union/etc/passwd | cut -d ':' -f1) - - clear - echo - echo -n "What is your username? [$username] " - read name - - if [ -z "$name" ]; then - name="$username" - fi - - echo - echo - chroot $tmpdir/union passwd $name - echo - echo - - return 0 -} - -function cleanup() { - - chroot $tmpdir/union /usr/bin/unicode_stop - - umount $tmpdir/union > /dev/null 2>&1 - lumount $tmpdir/user > /dev/null 2>&1 - lumount $tmpdir/squash > /dev/null 2>&1 - umount $rootdir > /dev/null 2>&1 - - rmdir $tmpdir/union $tmpdir/user $tmpdir/squash 2> /dev/null - rmdir $rootdir $tmpdir 2> /dev/null -} - -clear -trap cleanup SIGINT - -version="" -if ! insert_pendrive; then - exit 1 -fi - -sys_loop="$rootdir$loopbacks_rel/system.loop" -sfs_loop= # - -if ! prepare; then - cleanup - exit 1 -fi - -if ! doit; then - cleanup - exit 1 -fi - -cleanup -exit 0 diff --git a/rescue/Flash/scripts/restore_systemloop b/rescue/Flash/scripts/restore_systemloop deleted file mode 100755 index 39c56e030..000000000 --- a/rescue/Flash/scripts/restore_systemloop +++ /dev/null @@ -1,167 +0,0 @@ -#!/bin/bash - -# import functions library -source rescue_common - -tmpdir="/tmp/flash-rescue-root" -rootdir="$tmpdir/pen" - -function prepare() { - - mkdir -p $rootdir - - if ! mount_usbroot $rootdir; then - return 1 - fi - - if [ x"$version" = x"1.0" ]; then - mkdir -p $tmpdir/shared - if ! mount_sharedroot $tmpdir/shared; then - return 1 - fi - fi - - return 0 -} - -function doit() { - - if [ ! -d $dir ]; then - echo - echo "Can't find a backup directory in the Share partition" - echo - return 0 - fi - - cd $dir - i=1 - for file in $(ls -c1 backup-*.bz2 2> /dev/null | sort -r | head -10); do - files[$i]="$file" - let i++ - done - cd - > /dev/null - - if [ $i -eq 1 ]; then - echo - echo 'No backup files found!' - echo - return 0 - fi - - while [ true ]; do - - clear - echo - echo "The following backup files were found:" - echo - - i=1 - while [ -n "${files[$i]}" ]; do - echo "[$i] ${files[$i]}" - let i++ - done - let i-- - echo - echo '[0] Cancel / Return to main menu' - - echo - echo 'Select from the list above, the file that you want to restore.' - echo 'The most recent files come first in the list.' - echo - echo -n "What backup file do you want to restore? [1] " - read option - - if [ -z "$option" ]; then - option=1 - fi - if [ x"$option" = x"0" ]; then - return 0 - fi - - if [ ! -f $dir/${files[$option]} ]; then - echo - echo "Error reading backup file ${files[$option]}!" - echo - echo -n 'Do you want to restore another backup file? [N/y] ' - read confirm - - if [ x"$confirm" = x"y" -o x"$confirm" = x"Y" ]; then - continue - else - return 0 - fi - else - - echo - echo -n 'Restoring backup file. This can take some time: ' - - bunzip2 -c $dir/${files[$option]} > $loop \ - 2> /tmp/rescue-backup.err & - - sleep 2 - - while ps | grep -q bunzip2; do - progress - done - - sync - echo - echo - - errsize=$(ls -la /tmp/rescue-backup.err | cut -d' ' -f5) - if [ $errsize -ne 0 ]; then - echo 'Error restoring user files!' - echo - return 1 - else - echo 'Backup file restored!' - echo - break - fi - fi - done - - return 0 -} - -function cleanup() { - - if [ x"$version" = x"1.0" ]; then - umount $tmpdir/shared > /dev/null 2>&1 - rmdir $tmpdir/shared 2> /dev/null - fi - - umount $rootdir > /dev/null 2>&1 - rmdir $rootdir $tmpdir 2> /dev/null - - return 0 -} - -clear -trap cleanup SIGINT - -version="" -if ! insert_pendrive; then - exit 1 -fi - -if [ x"$version" = x"1.0" ]; then - dir="$tmpdir/shared/backup" - loop="$rootdir/loopbacks/system.loop" -else - dir="$rootdir/backup" - loop="$rootdir/.loopbacks/system.loop" -fi - -if ! prepare; then - cleanup - exit 1 -fi - -if ! doit; then - cleanup - exit 1 -fi - -cleanup -exit 0 diff --git a/rescue/Flash/scripts/test_badblocks b/rescue/Flash/scripts/test_badblocks deleted file mode 100755 index 3fb1f34d8..000000000 --- a/rescue/Flash/scripts/test_badblocks +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/bash - -# import functions library -source rescue_common - -tmpdir="/tmp/flash-rescue-root" -rootdir="$tmpdir/pen" - -function prepare() { - - return 0 -} - -function doit() { - - clear - echo - echo "WARNING!" - echo - echo "Searching for bad blocks in Mandriva Flash is a slow process." - echo - echo -n "Do you want to continue? [N/y] " - read confirm - - echo - echo - - device=$(cat /tmp/rescue-device) - - if [ x"$confirm" = x"y" -o x"$confirm" = x"Y" ]; then - - /sbin/badblocks -n -v -s ${device}1 - if [ x"$version" = x"1.0" ]; then - /sbin/badblocks -n -v -s ${device}2 - fi - fi - - echo - echo 'Bad blocks scan completed!' - echo - - return 0 -} - -function cleanup() { - - umount $rootdir > /dev/null 2>&1 - rmdir $rootdir $tmpdir 2> /dev/null -} - -clear -trap cleanup SIGINT - -version="" -if ! insert_pendrive; then - exit 1 -fi - -if ! prepare; then - cleanup - exit 1 -fi - -if ! doit; then - cleanup - exit 1 -fi - -cleanup diff --git a/rescue/Flash/scripts/upgrade b/rescue/Flash/scripts/upgrade deleted file mode 100755 index 87510b421..000000000 --- a/rescue/Flash/scripts/upgrade +++ /dev/null @@ -1,307 +0,0 @@ -#!/bin/bash - -# import functions library -source rescue_common - -tmpdir="/tmp/flash-rescue-root" -rootdir="$tmpdir/pen" - -media_dir="/tmp/media" -upgrade_dir="$media_dir/upgrade" - - -config_files_network_scripts="etc/sysconfig/network-scripts/ifcfg-* \ - etc/sysconfig/network-scripts/cellular.d \ - etc/sysconfig/network-scripts/vpn.d \ - etc/sysconfig/network-scripts/wireless.d" - -config_files_users="etc/passwd etc/shadow etc/group etc/gshadow" -config_files_time="etc/localtime etc/ntp etc/ntp.conf" -config_files="etc/sysconfig/* $config_files_users $config_files_time \ - etc/wpa_supplicant.conf etc/shorewall etc/kde \ - etc/udev/rules.d/61-*_config.rules" - -config_files_to_remove="etc/sysconfig/harddrake2" - -mozilla_files=".apps/FirefoxPortable/Data/profile/*.sqlite \ - .apps/FirefoxPortable/Data/profile/prefs.js \ - .apps/FirefoxPortable/Data/profile/key3.db \ - .apps/FirefoxPortable/Data/profile/signons*.txt \ - .apps/FirefoxPortable/Data/profile/Bookmarks.html \ - .apps/FirefoxPortable/Data/profile/Cookies.txt \ - .apps/FirefoxPortable/Data/profile/Downloads.rdf \ - .apps/FirefoxPortable/Data/profile/History.dat \ - .apps/ThunderbirdPortable/Data/profile/prefs.js \ - .apps/ThunderbirdPortable/Data/profile/abook.mab \ - .apps/ThunderbirdPortable/Data/profile/Mail \ - .apps/ThunderbirdPortable/Data/profile/ImapMail" - -function prepare() { - - echo "Mounting Mandriva Flash key..." - echo - - modprobe unionfs > /dev/null 2>&1 - modprobe sqlzma > /dev/null 2>&1 - modprobe squashfs-lzma > /dev/null 2>&1 - modprobe squashfs > /dev/null 2>&1 - modprobe loop > /dev/null 2>&1 - - mkdir -p $rootdir - mkdir -p $tmpdir/squash - mkdir -p $tmpdir/user - mkdir -p $tmpdir/union - - if ! mount_usbroot $rootdir; then - return 1 - fi - - set_sfs_loop $rootdir - - mount -t ext2 -o loop $sys_loop $tmpdir/user > /dev/null 2>&1 - if [ $? -ne 0 ]; then - echo "Error mounting system.loop" - return 1 - fi - - return 0 -} - -function get_existing_rpms() { - - echo "Getting list of installed packages..." - echo - - mount -t squashfs -o loop $sfs_loop $tmpdir/squash > /dev/null 2>&1 - if [ $? -ne 0 ]; then - echo "Error mounting distrib.sqfs" - return 1 - fi - - mount -t unionfs -o dirs=$tmpdir/user=rw:$tmpdir/squash=ro \ - none $tmpdir/union - if [ $? -ne 0 ]; then - echo "Error creating union of distrib.sqfs and system.loop" - return 1 - fi - - chroot $tmpdir/squash rpm -qa | sort > /tmp/previous_rpms.list - if [ $? -ne 0 ]; then - echo "Error getting list of vanilla rpms installed on previous key" - fi - - chroot $tmpdir/union rpm -qa | sort > /tmp/existing_rpms.list - if [ $? -ne 0 ]; then - echo "Error getting list of rpms installed prior to upgrade" - fi - - umount $tmpdir/union > /dev/null 2>&1 - lumount $tmpdir/squash > /dev/null 2>&1 - - mkdir -p $tmpdir/user/root - diff /tmp/previous_rpms.list /tmp/existing_rpms.list | sed -n 's/^> //p' > $tmpdir/user/root/new_existing_rpms.list - - return 0 -} - -function move_files() { - for i in $*; do - if [ -e $i ]; then - dir=`dirname $i` - [ "$dir" = "." ] || mkdir -p ..keep/$dir - mv $i ..keep/$dir || { echo "Error moving $i"; return 1; } - fi - done - - return 0 -} - -function remove_non_user_nor_config_files() { - - echo "Filtering system configuration files and user accounts..." - echo - - cd $tmpdir/user - - rm -rf $config_files_to_remove - - if [ -e ..keep ]; then - mv ..keep ..keep.bak - fi - if [ -e ..keep ]; then - echo "remove_non_user_nor_config_files can't work with existing temp dir" - return 1 - fi - - mkdir ..keep - - move_files $config_files_network_scripts || return 1 - rm -rf etc/sysconfig/network-scripts - - move_files home root $config_files || return 1 - rm -rf * - rm -rf .[^.]* - - mv ..keep/* . - rmdir ..keep - - cd - > /dev/null - - return 0 -} - -function backup_portable_apps_user_data() { - echo "Backing up Firefox and Thunderbird user data..." - echo - - cd $rootdir - - if [ -e ..keep ]; then - mv ..keep ..keep.bak - fi - - if [ -e ..keep ]; then - echo "remove_non_user_nor_config_files can't work with existing temp dir" - return 1 - fi - - mkdir ..keep - - move_files $mozilla_files - - cd - > /dev/null - - return 0 -} - -function restore_portable_apps_user_data() { - echo "Restoring Firefox and Thunderbird user data..." - echo - - cd $rootdir/..keep || return 1 - tar c -C $rootdir/..keep . | tar x -C $rootdir - rm -rf $rootdir/..keep - cd - > /dev/null - - return 0 -} - -function copy_new_version() { - - echo "Copying new Mandriva Flash system..." - - rm -rf $rootdir$boot_rel - rm -f $rootdir$loopbacks_rel/.*sqf - rm -f $rootdir$loopbacks_rel/.*sqfs - [ -d "$modules_dir" ] && rm -rf $modules_dir - - tar c -C $upgrade_dir . | pv -s `du -sb $upgrade_dir | cut -f 1` | tar x -C $rootdir - echo - - chmod -R u+w $rootdir - chmod -R u-w $rootdir$boot_rel $rootdir$loopbacks_rel - - new_label=$(source_version_variables "2.05"; echo $label) - MTOOLS_SKIP_CHECK=1 mlabel -i $usbroot_device ::$new_label - - return 0 -} - -function merge_config_files() { - - echo "Merging user and group accounts in new system..." - echo - - mount -t squashfs -o loop $sfs_loop $tmpdir/squash > /dev/null 2>&1 - if [ $? -ne 0 ]; then - echo "Error mounting distrib.sqfs" - return 1 - fi - - upgrade.merge-users $tmpdir/user/etc $tmpdir/squash/etc - - mount -t unionfs -o dirs=$tmpdir/user=rw:$tmpdir/squash=ro \ - none $tmpdir/union - if [ $? -ne 0 ]; then - echo "Error creating union of distrib.sqfs and system.loop" - return 1 - fi - - #- reapply lang configuration, mostly to rewrite kdeglobals - chroot $tmpdir/union perl -I/usr/lib/libDrakX -Mlang -e "lang::write(lang::read())" &>/dev/null - - #- remove KDE sessions file so that previous compiz usage does not break session - rm -f $tmpdir/union/home/*/.kde/share/config/ksmserverrc &>/dev/null - - #- remove KDE autostart files that should have been migrated by startkde... - rm -f $tmpdir/union/home/*/.kde/Autostart/{alignment-icons,openkmenu}.desktop &>/dev/null - - return 0 -} - -function doit() { - - if [ -d $tmpdir/user/var/lib/rpm/Packages ]; then - get_existing_rpms || return 1 - fi - - remove_non_user_nor_config_files || return 1 - - backup_portable_apps_user_data || return 1 - - copy_new_version || return 1 - - restore_portable_apps_user_data || return 1 - - merge_config_files || return 1 - - return 0 -} - -function cleanup() { - cd / - - umount $tmpdir/union > /dev/null 2>&1 - lumount $tmpdir/user > /dev/null 2>&1 - lumount $tmpdir/squash > /dev/null 2>&1 - umount $rootdir > /dev/null 2>&1 - - rmdir $tmpdir/union $tmpdir/user $tmpdir/squash 2> /dev/null - rmdir $rootdir $tmpdir 2> /dev/null -} - -clear -trap cleanup SIGINT - -version="" -if ! insert_pendrive; then - exit 1 -fi - -#- works only when upgrading versions with the same layout -sys_loop="$rootdir$loopbacks_rel/system.loop" -sfs_loop= # - -modules_dir="$rootdir$loopbacks_rel/modules" - -echo - -if ! prepare; then - cleanup - exit 1 -fi - -if ! doit; then - cleanup - exit 1 -fi - -echo "Please wait, finishing copy to key..." -echo - -cleanup - -echo "Congratulations! Your Mandriva Flash system is now upgraded." -echo - -exit 0 diff --git a/rescue/Flash/scripts/upgrade.merge-users b/rescue/Flash/scripts/upgrade.merge-users deleted file mode 100755 index 297960e91..000000000 --- a/rescue/Flash/scripts/upgrade.merge-users +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/perl - -use MDK::Common; - -@ARGV == 2 or die "merge_users <existing files dir> <new files dir>\n"; - -my ($existing_dir, $new_dir) = @ARGV; - -merge('passwd', 'shadow'); -merge('group', 'gshadow'); - -sub merge { - my ($main, $shadow) = @_; - - my @new = cat_("$new_dir/$main"); - my %new_ids = map { (split ':')[2] => $_ } @new; - - my %names_to_have; - foreach (cat_("$existing_dir/$main")) { - my @l = split ':'; - next if $l[0] eq 'nobody' || $l[2] < 500; - if (my $e = $new_ids{$l[2]}) { - $_ eq $e or warn "ERROR: conflicting entries:\n $_ $e"; - } else { - push @new, $_; - $names_to_have{$l[0]} = 1; - } - } - - my @new_shadow = grep { !/^root:/ } cat_("$new_dir/$shadow"); - foreach (cat_("$existing_dir/$shadow")) { - my ($name) = split ':'; - if ($name eq 'root') { - unshift @new_shadow, $_; - } elsif ($names_to_have{$name}) { - push @new_shadow, $_; - } - } - - if (rename "$existing_dir/$main", "$existing_dir/$main.old") { - output("$existing_dir/$main", @new); - } else { - warn "rename $existing_dir/$main failed: $?\n"; - <STDIN>; - } - if (rename "$existing_dir/$shadow", "$existing_dir/$shadow.old") { - output("$existing_dir/$shadow", @new_shadow); - } else { - warn "rename $existing_dir/$shadow failed: $?\n"; - <STDIN>; - } -} |