named backup
This commit is contained in:
parent
da15757dde
commit
6d4b865516
@ -6,11 +6,12 @@ trap on_error SIGINT SIGTERM ERR
|
|||||||
ScriptFullname=$(readlink -e "$0")
|
ScriptFullname=$(readlink -e "$0")
|
||||||
ScriptName=$(basename "$0")
|
ScriptName=$(basename "$0")
|
||||||
TargetFile=""
|
TargetFile=""
|
||||||
|
BackupFile=""
|
||||||
|
|
||||||
function show_help ()
|
function show_help ()
|
||||||
{
|
{
|
||||||
echo "Usage:"
|
echo "Usage:"
|
||||||
echo "${ScriptName} FILENAME patch specified kf2 executable"
|
echo "${ScriptName} FILENAME [BACKUPNAME] patch specified kf2 executable"
|
||||||
echo "${ScriptName} -h, --help show help"
|
echo "${ScriptName} -h, --help show help"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Dependencies: dd, readelf, hexdump"
|
echo "Dependencies: dd, readelf, hexdump"
|
||||||
@ -25,13 +26,19 @@ function on_error ()
|
|||||||
|
|
||||||
function backup ()
|
function backup ()
|
||||||
{
|
{
|
||||||
cp -f "$TargetFile" "$TargetFile.orig"
|
if [[ -z "$BackupFile" ]]; then
|
||||||
|
BackupFile="$TargetFile.orig"
|
||||||
|
fi
|
||||||
|
cp -f "$TargetFile" "$BackupFile"
|
||||||
}
|
}
|
||||||
|
|
||||||
function restore ()
|
function restore ()
|
||||||
{
|
{
|
||||||
if [[ -e "$TargetFile.orig" ]]; then
|
if [[ -z "$BackupFile" ]]; then
|
||||||
mv -f "$TargetFile.orig" "$TargetFile"
|
BackupFile="$TargetFile.orig"
|
||||||
|
fi
|
||||||
|
if [[ -e "$BackupFile" ]]; then
|
||||||
|
mv -f "$BackupFile" "$TargetFile"
|
||||||
echo "Original executable restored"
|
echo "Original executable restored"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -95,5 +102,5 @@ function main ()
|
|||||||
if [[ $# -eq 0 ]]; then show_help; exit 0; fi
|
if [[ $# -eq 0 ]]; then show_help; exit 0; fi
|
||||||
case $1 in
|
case $1 in
|
||||||
-h|--help ) show_help ; ;;
|
-h|--help ) show_help ; ;;
|
||||||
* ) TargetFile="$1"; main ;;
|
* ) TargetFile="$1"; BackupFile="$2"; main ;;
|
||||||
esac
|
esac
|
||||||
|
Loading…
Reference in New Issue
Block a user