forked from Blendman974/faceclaw
Scripts to push/pull config take arguments
This commit is contained in:
1 parent
c1d70abf5e
commit
2d45b65098
3 files changed
+93
-5
No files matched your search
+55
-1
@@ -1,6 +1,58 @@
|
|||||||
# Sourceable adb helper functions shared by the scripts/ utilities.
|
# Sourceable adb helper functions shared by the scripts/ utilities.
|
||||||
# Not a standalone script; use: source "$(dirname "$0")/adbutil.sh"
|
# Not a standalone script; use: source "$(dirname "$0")/adbutil.sh"
|
||||||
|
|
||||||
|
# Extra arguments (e.g. -s SERIAL) inserted before every adb subcommand.
|
||||||
|
# Filled in by adbutil_parse_args; the wrapper below makes them apply to all
|
||||||
|
# plain `adb ...` calls in the sourcing script.
|
||||||
|
ADB_ARGS=()
|
||||||
|
adb() {
|
||||||
|
command adb ${ADB_ARGS[@]+"${ADB_ARGS[@]}"} "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
# adbutil_parse_args "$@"
|
||||||
|
#
|
||||||
|
# Shared command-line parsing for the settings-port scripts. Sets:
|
||||||
|
# ADBUTIL_FILE - local settings file: a bare first argument, or the value
|
||||||
|
# of -f FILE anywhere in the argument list; empty if neither
|
||||||
|
# was given (caller applies its default)
|
||||||
|
# ADBUTIL_HELP - 1 if -h/--help appeared anywhere, else 0
|
||||||
|
# Everything else is collected into ADB_ARGS and passed through to adb
|
||||||
|
# (e.g. -s SERIAL or -t ID to pick one of several attached devices).
|
||||||
|
adbutil_parse_args() {
|
||||||
|
ADBUTIL_FILE=""
|
||||||
|
ADBUTIL_HELP=0
|
||||||
|
local first=1
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
case "$1" in
|
||||||
|
-h|--help)
|
||||||
|
ADBUTIL_HELP=1
|
||||||
|
;;
|
||||||
|
-f)
|
||||||
|
if [ $# -lt 2 ]; then
|
||||||
|
echo "Error: -f requires a filename" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
ADBUTIL_FILE="$2"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-*)
|
||||||
|
ADB_ARGS+=("$1")
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# A bare first argument is the filename; later bare arguments
|
||||||
|
# are passed through (they're values for adb flags like -s).
|
||||||
|
if [ "$first" = 1 ]; then
|
||||||
|
ADBUTIL_FILE="$1"
|
||||||
|
else
|
||||||
|
ADB_ARGS+=("$1")
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
first=0
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# adb_preflight <package>
|
# adb_preflight <package>
|
||||||
#
|
#
|
||||||
# Checks that adb exists, exactly one device is reachable, and <package> is
|
# Checks that adb exists, exactly one device is reachable, and <package> is
|
||||||
@@ -13,7 +65,9 @@ adb_preflight() {
|
|||||||
local package="$1"
|
local package="$1"
|
||||||
local state
|
local state
|
||||||
|
|
||||||
if ! command -v adb >/dev/null 2>&1; then
|
# type -P checks PATH only, so the adb wrapper function above doesn't
|
||||||
|
# satisfy the check.
|
||||||
|
if ! type -P adb >/dev/null 2>&1; then
|
||||||
echo "Error: adb not found on PATH" >&2
|
echo "Error: adb not found on PATH" >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
+19
-2
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Pull faceclaw's shared preferences off the attached device.
|
# Pull faceclaw's shared preferences off the attached device.
|
||||||
# Usage: pull_config.sh [output-file] (default: faceclaw_settings.xml)
|
# Usage: pull_config.sh [output-file] [-f output-file] [adb-options...]
|
||||||
#
|
#
|
||||||
# Uses run-as on debuggable (dev) builds. On release builds, where run-as is
|
# Uses run-as on debuggable (dev) builds. On release builds, where run-as is
|
||||||
# refused, falls back to the FaceclawSettingsPortReceiver broadcast, which
|
# refused, falls back to the FaceclawSettingsPortReceiver broadcast, which
|
||||||
@@ -10,9 +10,26 @@ set -euo pipefail
|
|||||||
|
|
||||||
source "$(cd "$(dirname "$0")" && pwd)/adbutil.sh"
|
source "$(cd "$(dirname "$0")" && pwd)/adbutil.sh"
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat <<EOF
|
||||||
|
Usage: $(basename "$0") [output-file] [-f output-file] [adb-options...]
|
||||||
|
|
||||||
|
Pull faceclaw's shared preferences off the attached device into output-file
|
||||||
|
(default: faceclaw_settings.xml). The output file may be given as a bare
|
||||||
|
first argument or with -f anywhere. Any other arguments are passed through
|
||||||
|
to adb, e.g. -s SERIAL or -t ID to pick one of several attached devices.
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
adbutil_parse_args "$@"
|
||||||
|
if [ "$ADBUTIL_HELP" = 1 ]; then
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
PACKAGE=com.faceclaw.app
|
PACKAGE=com.faceclaw.app
|
||||||
PREFS=shared_prefs/faceclaw_settings.xml
|
PREFS=shared_prefs/faceclaw_settings.xml
|
||||||
OUT="${1:-faceclaw_settings.xml}"
|
OUT="${ADBUTIL_FILE:-faceclaw_settings.xml}"
|
||||||
EXPORT_REMOTE=/sdcard/Android/data/$PACKAGE/files/faceclaw-settings-export.xml
|
EXPORT_REMOTE=/sdcard/Android/data/$PACKAGE/files/faceclaw-settings-export.xml
|
||||||
|
|
||||||
MODE="$(adb_preflight "$PACKAGE")"
|
MODE="$(adb_preflight "$PACKAGE")"
|
||||||
|
|||||||
+19
-2
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Push a shared-preferences file to faceclaw on the attached device.
|
# Push a shared-preferences file to faceclaw on the attached device.
|
||||||
# Usage: push_config.sh [input-file] (default: faceclaw_settings.xml)
|
# Usage: push_config.sh [input-file] [-f input-file] [adb-options...]
|
||||||
# Validates the XML, force-stops the app (so a running instance doesn't
|
# Validates the XML, force-stops the app (so a running instance doesn't
|
||||||
# overwrite the pushed file from its in-memory prefs), then installs it.
|
# overwrite the pushed file from its in-memory prefs), then installs it.
|
||||||
#
|
#
|
||||||
@@ -13,9 +13,26 @@ set -euo pipefail
|
|||||||
|
|
||||||
source "$(cd "$(dirname "$0")" && pwd)/adbutil.sh"
|
source "$(cd "$(dirname "$0")" && pwd)/adbutil.sh"
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat <<EOF
|
||||||
|
Usage: $(basename "$0") [input-file] [-f input-file] [adb-options...]
|
||||||
|
|
||||||
|
Push input-file (default: faceclaw_settings.xml) as faceclaw's shared
|
||||||
|
preferences on the attached device. The input file may be given as a bare
|
||||||
|
first argument or with -f anywhere. Any other arguments are passed through
|
||||||
|
to adb, e.g. -s SERIAL or -t ID to pick one of several attached devices.
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
adbutil_parse_args "$@"
|
||||||
|
if [ "$ADBUTIL_HELP" = 1 ]; then
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
PACKAGE=com.faceclaw.app
|
PACKAGE=com.faceclaw.app
|
||||||
PREFS=shared_prefs/faceclaw_settings.xml
|
PREFS=shared_prefs/faceclaw_settings.xml
|
||||||
IN="${1:-faceclaw_settings.xml}"
|
IN="${ADBUTIL_FILE:-faceclaw_settings.xml}"
|
||||||
STAGE=/data/local/tmp/faceclaw_settings_push.xml
|
STAGE=/data/local/tmp/faceclaw_settings_push.xml
|
||||||
IMPORT_REMOTE=/sdcard/Android/data/$PACKAGE/files/faceclaw-settings-import.xml
|
IMPORT_REMOTE=/sdcard/Android/data/$PACKAGE/files/faceclaw-settings-import.xml
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user