mirror of
https://github.com/arkenfox/user.js.git
synced 2025-05-03 23:43:40 +02:00
add option to keep only one backup
This commit is contained in:
parent
c3e652574e
commit
6545b28962
1 changed files with 12 additions and 2 deletions
14
updater.sh
14
updater.sh
|
@ -39,12 +39,13 @@ ff_profile="$(dirname "${sfp}")"
|
||||||
#########################
|
#########################
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo -e ${BLUE}"\nUsage: $0 [-h] [-u] [-d] [-s] [-n] [-o OVERRIDE]\n"${NC} 1>&2 # Echo usage string to standard error
|
echo -e ${BLUE}"\nUsage: $0 [-h] [-u] [-d] [-s] [-n] [-b] [-o OVERRIDE]\n"${NC} 1>&2 # Echo usage string to standard error
|
||||||
echo -e "Optional Arguments:"
|
echo -e "Optional Arguments:"
|
||||||
echo -e "\t-h,\t\t Show this help message and exit."
|
echo -e "\t-h,\t\t Show this help message and exit."
|
||||||
echo -e "\t-u,\t\t Update updater.sh and execute silently. Do not seek confirmation."
|
echo -e "\t-u,\t\t Update updater.sh and execute silently. Do not seek confirmation."
|
||||||
echo -e "\t-d,\t\t Do not look for updates to updater.sh."
|
echo -e "\t-d,\t\t Do not look for updates to updater.sh."
|
||||||
echo -e "\t-s,\t\t Silently update user.js. Do not seek confirmation."
|
echo -e "\t-s,\t\t Silently update user.js. Do not seek confirmation."
|
||||||
|
echo -e "\t-b,\t\t Only keep one backup of each file."
|
||||||
echo -e "\t-o OVERRIDE,\t Filename or path to overrides file (if different than user-overrides.js)."
|
echo -e "\t-o OVERRIDE,\t Filename or path to overrides file (if different than user-overrides.js)."
|
||||||
echo -e "\t-n,\t\t Do not append any overrides, evein if user-overrides.js exists."
|
echo -e "\t-n,\t\t Do not append any overrides, evein if user-overrides.js exists."
|
||||||
echo -e
|
echo -e
|
||||||
|
@ -62,6 +63,7 @@ legacy_argument () {
|
||||||
UPDATE="check"
|
UPDATE="check"
|
||||||
CONFIRM="yes"
|
CONFIRM="yes"
|
||||||
OVERRIDE="user-overrides.js"
|
OVERRIDE="user-overrides.js"
|
||||||
|
BACKUP="multiple"
|
||||||
|
|
||||||
|
|
||||||
if [ $# != 0 ]; then
|
if [ $# != 0 ]; then
|
||||||
|
@ -75,7 +77,7 @@ if [ $# != 0 ]; then
|
||||||
UPDATE="yes"
|
UPDATE="yes"
|
||||||
legacy_argument $1
|
legacy_argument $1
|
||||||
else
|
else
|
||||||
while getopts ":hudso:n" opt; do
|
while getopts ":hudso:nb" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
h)
|
h)
|
||||||
usage
|
usage
|
||||||
|
@ -95,6 +97,9 @@ if [ $# != 0 ]; then
|
||||||
n)
|
n)
|
||||||
OVERRIDE="none"
|
OVERRIDE="none"
|
||||||
;;
|
;;
|
||||||
|
b)
|
||||||
|
BACKUP="single"
|
||||||
|
;;
|
||||||
\?)
|
\?)
|
||||||
echo -e ${RED}"\nInvalid option: -$OPTARG"${NC} >&2
|
echo -e ${RED}"\nInvalid option: -$OPTARG"${NC} >&2
|
||||||
usage
|
usage
|
||||||
|
@ -154,6 +159,11 @@ download_file () {
|
||||||
backup_file () {
|
backup_file () {
|
||||||
filename=$1
|
filename=$1
|
||||||
mkdir -p userjs_backups
|
mkdir -p userjs_backups
|
||||||
|
if [ $BACKUP = "single" ]; then
|
||||||
|
cd userjs_backups
|
||||||
|
find . -type f -name $filename\* -exec rm {} \;
|
||||||
|
cd ..
|
||||||
|
fi
|
||||||
mv $filename "userjs_backups/${filename}.backup.$(date +"%Y-%m-%d_%H%M")"
|
mv $filename "userjs_backups/${filename}.backup.$(date +"%Y-%m-%d_%H%M")"
|
||||||
mv "userjs_temps/${filename}" $filename
|
mv "userjs_temps/${filename}" $filename
|
||||||
echo -e "Status: ${GREEN}${filename} has been backed up and replaced with the latest version!${NC}"
|
echo -e "Status: ${GREEN}${filename} has been backed up and replaced with the latest version!${NC}"
|
||||||
|
|
Loading…
Add table
Reference in a new issue