design improvements, stabilize everything, update readme
This commit is contained in:
parent
48736645c5
commit
0ceb0b61b4
8 changed files with 979 additions and 511 deletions
|
@ -1,8 +1,10 @@
|
|||
function show_usage() {
|
||||
echo "Usage: $0 [-e <email>] [-s <server>]"
|
||||
echo "Usage: $0 [-e <email>] [-s <server>] [-v] [-d]"
|
||||
echo "Options:"
|
||||
echo " -e Email address"
|
||||
echo " -s Server URL"
|
||||
echo " -e <email> Set email address"
|
||||
echo " -s <server> Set server URL"
|
||||
echo " -v Get module version"
|
||||
echo " -d Get debug mode status"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
@ -12,11 +14,14 @@ function set_email() {
|
|||
show_usage
|
||||
fi
|
||||
|
||||
if ! grep -q "EMAIL=" /data/adb/beesrv/config.txt; then
|
||||
echo "EMAIL=$1" >> /data/adb/beesrv/config.txt
|
||||
else
|
||||
sed -i "s/EMAIL=.*/EMAIL=$1/" /data/adb/beesrv/config.txt
|
||||
fi
|
||||
local email="$1"
|
||||
local config_file="/data/adb/beesrv/config.txt"
|
||||
|
||||
touch "$config_file"
|
||||
|
||||
grep -v "^EMAIL=" "$config_file" > "$config_file.tmp" 2>/dev/null || true
|
||||
echo "EMAIL=$email" >> "$config_file.tmp"
|
||||
mv "$config_file.tmp" "$config_file"
|
||||
|
||||
echo "Success"
|
||||
}
|
||||
|
@ -27,16 +32,39 @@ function set_server() {
|
|||
show_usage
|
||||
fi
|
||||
|
||||
if ! grep -q "SERVER=" /data/adb/beesrv/config.txt; then
|
||||
echo "SERVER=$1" >> /data/adb/beesrv/config.txt
|
||||
else
|
||||
sed -i "s/SERVER=.*/SERVER=$1/" /data/adb/beesrv/config.txt
|
||||
fi
|
||||
local server_url="$1"
|
||||
local config_file="/data/adb/beesrv/config.txt"
|
||||
|
||||
touch "$config_file"
|
||||
|
||||
grep -v "^SERVER=" "$config_file" > "$config_file.tmp" 2>/dev/null || true
|
||||
echo "SERVER=$server_url" >> "$config_file.tmp"
|
||||
mv "$config_file.tmp" "$config_file"
|
||||
|
||||
echo "Success"
|
||||
}
|
||||
|
||||
while getopts "e:s:" opt; do
|
||||
function get_version() {
|
||||
local mod_prop
|
||||
mod_prop="$(dirname "$0")/../module.prop"
|
||||
if [ -f "$mod_prop" ]; then
|
||||
version=$(grep "version=" "$mod_prop" | cut -d'=' -f2)
|
||||
echo "$version"
|
||||
else
|
||||
echo "Unknown"
|
||||
fi
|
||||
}
|
||||
|
||||
function get_debug_mode() {
|
||||
local config_file="/data/adb/beesrv/config.txt"
|
||||
if [ -f "$config_file" ] && grep -q "^DEBUG=true$" "$config_file"; then
|
||||
echo "true"
|
||||
else
|
||||
echo "false"
|
||||
fi
|
||||
}
|
||||
|
||||
while getopts "e:s:vd" opt; do
|
||||
case ${opt} in
|
||||
e )
|
||||
set_email "$OPTARG"
|
||||
|
@ -44,6 +72,12 @@ while getopts "e:s:" opt; do
|
|||
s )
|
||||
set_server "$OPTARG"
|
||||
;;
|
||||
v )
|
||||
get_version
|
||||
;;
|
||||
d )
|
||||
get_debug_mode
|
||||
;;
|
||||
\? )
|
||||
echo "[ERROR] Invalid option -$OPTARG"
|
||||
show_usage
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue