All pastes #943388 Raw Edit

PackageRestore

public shellscript v1 · immutable
·published 2008-03-15 06:06 UTC
rendered paste body
#! /bin/bashnochange(){    zenity --info --text "Package Backup and Restore Halted -- No Changes Made";    exit 0;}restore(){    if [ $UID -eq 0 ]        then        name=$(zenity --file-selection --text "Open file:" --filename ~/.system_restore/);        zenity --question --text "Install all packages?";                if [ $? -eq 0 ]         then            if [ -f $name ]            then                zenity --info --text "File exists and ready";                gksudo dpkg --set-selections < $name; dselect;            else                zenity --info --text "Not a file";                nochange;            fi        else            nochange;        fi    else        zenity --info --text "You are not root";        exit 0    fi    return;  }backup(){    saveas=$(zenity --entry --text "Save as:");         if [ -e ~/.system_restore/$saveas ]    then          if [ -d ~/.system_restore/$saveas ]        then            zenity --info --text "That is a directory";            nochange;        fi        zenity --question --text "File exists, overwrite?";        if [ $? -eq 0 ]         then            dpkg --get-selections > ~/.system_restore/$saveas;        else            exit;        fi            else        dpkg --get-selections > ~/.system_restore/$saveas;    fi    return;}main(){    mkdir ~/.system_restore;    ans=$(zenity  --list  --text "Package Backup and Restore" --radiolist  --column "Pick" --column "Option" TRUE "Backup" FALSE "Restore");    if [ $? -eq 1 ]    then        nochange;    else        if [ $ans == "Backup" ]         then            backup;        elif [ $ans == "Restore" ]        then            restore;        else            nochange;        fi    fi        }mainCLI(){    echo "CLI version not made.";}if [ $@ == "--no-gui" ] then    mainCLI;elif [ $@ == "-h" || $@ == "--help" ]then    echo "Use the --no-gui command line option to run in shell";else    main;fi