Automatically determine server ip address
This commit is contained in:
111
san
111
san
@@ -3,67 +3,82 @@ set -o vi
|
|||||||
# set -x
|
# set -x
|
||||||
alias ll='ls -la'
|
alias ll='ls -la'
|
||||||
|
|
||||||
if [ -z $SAN_SERVER_IP ]; then
|
|
||||||
SAN_SERVER_IP=192.168.0.64
|
source /nvram/san.conf
|
||||||
|
__config(){
|
||||||
|
local GATEWAY=$(ip route show 0.0.0.0/0 | sed 's/default via \([0-9.]*\) dev .*/\1/')
|
||||||
|
if [ -z $SERVER_IP ]; then
|
||||||
|
if [ "$GATEWAY" == "192.168.144.93" ]; then
|
||||||
|
SERVER_IP=192.168.144.5
|
||||||
|
else
|
||||||
|
SERVER_IP=192.168.0.64
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
__config
|
||||||
|
|
||||||
|
|
||||||
DESCR=""
|
DESCR=""
|
||||||
descr(){
|
__descr(){
|
||||||
# echo "$1"
|
# echo "$1"
|
||||||
DESCR="$DESCR\n$1"
|
DESCR="$DESCR\n$1"
|
||||||
}
|
}
|
||||||
header(){
|
__header(){
|
||||||
descr ""
|
__descr ""
|
||||||
descr " * $1"
|
__descr " * $1"
|
||||||
}
|
}
|
||||||
|
|
||||||
descr "Available Commands:"
|
################################################################################
|
||||||
descr " san_help - print this help."
|
#
|
||||||
|
#
|
||||||
|
__descr "Available Commands:"
|
||||||
|
__descr " san_help - print this help."
|
||||||
san_help()
|
san_help()
|
||||||
{
|
{
|
||||||
printf "$DESCR\n"
|
printf "$DESCR\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
UPDATE_SAN="wget -O /nvram/san http://$SAN_SERVER_IP/roku/san/san"
|
__descr " update_san - update this script."
|
||||||
descr " update_san - update this script."
|
|
||||||
descr " Manually: $UPDATE_SAN"
|
|
||||||
update_san()
|
update_san()
|
||||||
{
|
{
|
||||||
eval $UPDATE_SAN
|
|
||||||
|
wget -O /nvram/san http://$SERVER_IP/roku/san/san
|
||||||
source /nvram/san
|
source /nvram/san
|
||||||
}
|
}
|
||||||
|
|
||||||
descr " upload - upload through tftp. e.g. upload /dev/ltcore"
|
__descr " upload - upload through tftp. e.g. upload /dev/ltcore"
|
||||||
upload()
|
upload()
|
||||||
{
|
{
|
||||||
[ -e $1 ] && tftp -r $(basename $1) -l $1 -p $SAN_SERVER_IP
|
[ -e $1 ] && tftp -r $(basename $1) -l $1 -p $SERVER_IP
|
||||||
}
|
}
|
||||||
|
|
||||||
descr " upload_core - upload /dev/ltcore"
|
__descr " upload_core - upload /dev/ltcore"
|
||||||
upload_core()
|
upload_core()
|
||||||
{
|
{
|
||||||
upload /dev/ltcore
|
upload /dev/ltcore
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
descr " app_config - "
|
__descr " app_config - "
|
||||||
app_config()
|
app_config()
|
||||||
{
|
{
|
||||||
telnet 127.0.0.1 8080
|
telnet 127.0.0.1 8080
|
||||||
}
|
}
|
||||||
|
|
||||||
descr " factory_reset - "
|
__descr " factory_reset - "
|
||||||
factory_reset()
|
factory_reset()
|
||||||
{
|
{
|
||||||
touch /nvram/factoryresetflag2 && reboot
|
touch /nvram/factoryresetflag2 && reboot
|
||||||
}
|
}
|
||||||
|
|
||||||
descr " disable_wd - disable watchdog"
|
__descr " disable_wd - disable watchdog"
|
||||||
disable_wd()
|
disable_wd()
|
||||||
{
|
{
|
||||||
sh -c "while true ; do noreset; sleep 5; done" &
|
sh -c "while true ; do noreset; sleep 5; done" &
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Firmware flash.
|
# Firmware flash.
|
||||||
@@ -94,7 +109,7 @@ download_from_buildarea()
|
|||||||
|
|
||||||
download_firmware()
|
download_firmware()
|
||||||
{
|
{
|
||||||
ACRAMFS_URL="http://$SAN_SERVER_IP/roku/$1"
|
ACRAMFS_URL="http://$SERVER_IP/roku/$1"
|
||||||
echo "Downloading ${ACRAMFS_URL}"
|
echo "Downloading ${ACRAMFS_URL}"
|
||||||
wget -O ${ACRAMFS} ${ACRAMFS_URL}
|
wget -O ${ACRAMFS} ${ACRAMFS_URL}
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
@@ -135,7 +150,7 @@ update_firmware()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
descr " rokuflash [active|both] [main|main2|bailey_cert|golden|<acramfs path>] - empty flashes from build area"
|
__descr " rokuflash [active|both] [main|main2|bailey_cert|golden|<acramfs path>] - empty flashes from build area"
|
||||||
rokuflash()
|
rokuflash()
|
||||||
{
|
{
|
||||||
REMOTE_ACRAMFS=""
|
REMOTE_ACRAMFS=""
|
||||||
@@ -146,7 +161,7 @@ rokuflash()
|
|||||||
active|both)
|
active|both)
|
||||||
UPDATE_PARTITION="$1"
|
UPDATE_PARTITION="$1"
|
||||||
;;
|
;;
|
||||||
main|main2)
|
main|main2|main.svin)
|
||||||
BUILD_AREA="$1"
|
BUILD_AREA="$1"
|
||||||
;;
|
;;
|
||||||
bailey_cert)
|
bailey_cert)
|
||||||
@@ -176,8 +191,8 @@ rokuflash()
|
|||||||
# Ddd to the start of the script
|
# Ddd to the start of the script
|
||||||
# export APP_GDBSERVER="/nvram/tools/gdbserver :5555"ebug Server
|
# export APP_GDBSERVER="/nvram/tools/gdbserver :5555"ebug Server
|
||||||
#
|
#
|
||||||
header "GDB"
|
__header "GDB"
|
||||||
#descr " setup_gdb [seconds|app|zipmountserver|apibroker|apitrace]"
|
#__descr " setup_gdb [seconds|app|zipmountserver|apibroker|apitrace]"
|
||||||
#setup_gdb()
|
#setup_gdb()
|
||||||
#{
|
#{
|
||||||
# #copy tools to /nvram folder for example:
|
# #copy tools to /nvram folder for example:
|
||||||
@@ -222,7 +237,7 @@ launch_gdb()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
descr " enable_gdb [seconds|app|zipmountserver|apibroker|apitrace]"
|
__descr " enable_gdb [seconds|app|zipmountserver|apibroker|apitrace]"
|
||||||
enable_gdb()
|
enable_gdb()
|
||||||
{
|
{
|
||||||
[ ! -f /nvram/tools/gdbserver ] && cp -rL /tmp/tools /nvram/
|
[ ! -f /nvram/tools/gdbserver ] && cp -rL /tmp/tools /nvram/
|
||||||
@@ -237,7 +252,7 @@ enable_gdb()
|
|||||||
mv /tmp/autostart /nvram/
|
mv /tmp/autostart /nvram/
|
||||||
}
|
}
|
||||||
|
|
||||||
descr " disable_gdb - "
|
__descr " disable_gdb - "
|
||||||
disable_gdb()
|
disable_gdb()
|
||||||
{
|
{
|
||||||
[ -f /nvram/autostart ] && cat /nvram/autostart | sed '/launch_gdb/d' > /tmp/autostart
|
[ -f /nvram/autostart ] && cat /nvram/autostart | sed '/launch_gdb/d' > /tmp/autostart
|
||||||
@@ -245,7 +260,7 @@ disable_gdb()
|
|||||||
mv /tmp/autostart /nvram/
|
mv /tmp/autostart /nvram/
|
||||||
}
|
}
|
||||||
|
|
||||||
descr " tail_dmesg - "
|
__descr " tail_dmesg - "
|
||||||
tail_dmesg()
|
tail_dmesg()
|
||||||
{
|
{
|
||||||
while true; do
|
while true; do
|
||||||
@@ -256,9 +271,9 @@ tail_dmesg()
|
|||||||
###############################################################################v
|
###############################################################################v
|
||||||
# Tools
|
# Tools
|
||||||
#
|
#
|
||||||
header "Tools"
|
__header "Tools"
|
||||||
|
|
||||||
descr " zms_client <action> <mount> <file> {<swapto>} "
|
__descr " zms_client <action> <mount> <file> {<swapto>} "
|
||||||
zms_client()
|
zms_client()
|
||||||
{
|
{
|
||||||
if [ "$1" == "" -o "$1" == "help" ]; then
|
if [ "$1" == "" -o "$1" == "help" ]; then
|
||||||
@@ -300,9 +315,9 @@ zms_hotswap_stress_test()
|
|||||||
#
|
#
|
||||||
# Log
|
# Log
|
||||||
#
|
#
|
||||||
header "LOG"
|
__header "LOG"
|
||||||
LOG_CONF="/nvram/logapi.conf"
|
LOG_CONF="/nvram/logapi.conf"
|
||||||
descr " log_reset - reset log configuration"
|
__descr " log_reset - reset log configuration"
|
||||||
log_reset()
|
log_reset()
|
||||||
{
|
{
|
||||||
[ -f $LOG_CONF ] && rm $LOG_CONF
|
[ -f $LOG_CONF ] && rm $LOG_CONF
|
||||||
@@ -310,13 +325,13 @@ log_reset()
|
|||||||
echo "+e" >> $LOG_CONF
|
echo "+e" >> $LOG_CONF
|
||||||
}
|
}
|
||||||
|
|
||||||
descr " log_all - log everything"
|
__descr " log_all - log everything"
|
||||||
log_all()
|
log_all()
|
||||||
{
|
{
|
||||||
echo "+c *" >> $LOG_CONF
|
echo "+c *" >> $LOG_CONF
|
||||||
}
|
}
|
||||||
|
|
||||||
descr " log_seconds - show seconds."
|
__descr " log_seconds - show seconds."
|
||||||
log_seconds()
|
log_seconds()
|
||||||
{
|
{
|
||||||
echo "+e" >> $LOG_CONF
|
echo "+e" >> $LOG_CONF
|
||||||
@@ -326,14 +341,14 @@ log_seconds()
|
|||||||
#
|
#
|
||||||
# Config
|
# Config
|
||||||
#
|
#
|
||||||
header "Config"
|
__header "Config"
|
||||||
descr " config_reset - erase configuration"
|
__descr " config_reset - erase configuration"
|
||||||
config_reset()
|
config_reset()
|
||||||
{
|
{
|
||||||
su app -c "ConfigService -ro"
|
su app -c "ConfigService -ro"
|
||||||
}
|
}
|
||||||
|
|
||||||
descr " config_list - "
|
__descr " config_list - "
|
||||||
config_list()
|
config_list()
|
||||||
{
|
{
|
||||||
su app -c "ConfigService -lo"
|
su app -c "ConfigService -lo"
|
||||||
@@ -350,7 +365,7 @@ config_disable()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
descr " disable_failsafe - "
|
__descr " disable_failsafe - "
|
||||||
disable_failsafe()
|
disable_failsafe()
|
||||||
{
|
{
|
||||||
config_enable "fw.apibroker.failsafe-disable"
|
config_enable "fw.apibroker.failsafe-disable"
|
||||||
@@ -361,8 +376,8 @@ disable_failsafe()
|
|||||||
# Fastboot related
|
# Fastboot related
|
||||||
#
|
#
|
||||||
|
|
||||||
header "FastBoot"
|
__header "FastBoot"
|
||||||
descr " enable_fastboot - "
|
__descr " enable_fastboot - "
|
||||||
enable_fastboot()
|
enable_fastboot()
|
||||||
{
|
{
|
||||||
su app -c "ConfigService -so fw.fastboot.capture.snapshot=true"
|
su app -c "ConfigService -so fw.fastboot.capture.snapshot=true"
|
||||||
@@ -370,28 +385,28 @@ enable_fastboot()
|
|||||||
fastboot_reset
|
fastboot_reset
|
||||||
}
|
}
|
||||||
|
|
||||||
descr " disable_fastboot - "
|
__descr " disable_fastboot - "
|
||||||
disable_fastboot()
|
disable_fastboot()
|
||||||
{
|
{
|
||||||
su app -c "ConfigService -so fw.fastboot.capture.snapshot=false"
|
su app -c "ConfigService -so fw.fastboot.capture.snapshot=false"
|
||||||
fastboot_reset
|
fastboot_reset
|
||||||
}
|
}
|
||||||
|
|
||||||
descr " enable_fastboot2 - "
|
__descr " enable_fastboot2 - "
|
||||||
enable_fastboot2()
|
enable_fastboot2()
|
||||||
{
|
{
|
||||||
su app -c "ConfigService -so fw.fastboot.snapshot-after-precompile=true"
|
su app -c "ConfigService -so fw.fastboot.snapshot-after-precompile=true"
|
||||||
fastboot_reset
|
fastboot_reset
|
||||||
}
|
}
|
||||||
|
|
||||||
descr " disable_fastboot2 - "
|
__descr " disable_fastboot2 - "
|
||||||
disable_fastboot2()
|
disable_fastboot2()
|
||||||
{
|
{
|
||||||
su app -c "ConfigService -so fw.fastboot.snapshot-after-precompile=false"
|
su app -c "ConfigService -so fw.fastboot.snapshot-after-precompile=false"
|
||||||
fastboot_reset
|
fastboot_reset
|
||||||
}
|
}
|
||||||
|
|
||||||
descr " fastboot_reset - "
|
__descr " fastboot_reset - "
|
||||||
fastboot_reset()
|
fastboot_reset()
|
||||||
{
|
{
|
||||||
[ -e /dev/mapper/snapshotree ] && mkswap /dev/mapper/snapshotree
|
[ -e /dev/mapper/snapshotree ] && mkswap /dev/mapper/snapshotree
|
||||||
@@ -401,7 +416,7 @@ fastboot_reset()
|
|||||||
#
|
#
|
||||||
# Wifi Setup
|
# Wifi Setup
|
||||||
#
|
#
|
||||||
header "WiFi"
|
__header "WiFi"
|
||||||
IFACE=wlan0
|
IFACE=wlan0
|
||||||
wpa()
|
wpa()
|
||||||
{
|
{
|
||||||
@@ -415,7 +430,7 @@ set_office_network()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
descr " setup_wifi - "
|
__descr " setup_wifi - "
|
||||||
setup_wifi()
|
setup_wifi()
|
||||||
{
|
{
|
||||||
rm -f /tmp/wpa_ctrl/$IFACE
|
rm -f /tmp/wpa_ctrl/$IFACE
|
||||||
@@ -442,7 +457,7 @@ setup_wifi()
|
|||||||
ip a add $IP/22 dev $IFACE
|
ip a add $IP/22 dev $IFACE
|
||||||
}
|
}
|
||||||
|
|
||||||
descr " setup_network - "
|
__descr " setup_network - "
|
||||||
setup_network()
|
setup_network()
|
||||||
{
|
{
|
||||||
/sbin/udhcpc -i eth0 -s /etc/udhcpc.sh
|
/sbin/udhcpc -i eth0 -s /etc/udhcpc.sh
|
||||||
@@ -454,7 +469,7 @@ alias ll='ls -la'
|
|||||||
#
|
#
|
||||||
# Plugfest
|
# Plugfest
|
||||||
#
|
#
|
||||||
descr " setup_plugfest - "
|
__descr " setup_plugfest - "
|
||||||
setup_plugfest()
|
setup_plugfest()
|
||||||
{
|
{
|
||||||
[ -f $LOG_CONF ] && rm $LOG_CONF
|
[ -f $LOG_CONF ] && rm $LOG_CONF
|
||||||
@@ -481,14 +496,14 @@ setup_plugfest()
|
|||||||
#
|
#
|
||||||
# Done
|
# Done
|
||||||
#
|
#
|
||||||
descr " setup_san - "
|
__descr " setup_san - "
|
||||||
setup_san()
|
setup_san()
|
||||||
{
|
{
|
||||||
grep /nvram/san /nvram/autostart > /dev/null
|
grep /nvram/san /nvram/autostart > /dev/null
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
cat > /nvram/autostart << EOF
|
cat > /nvram/autostart << EOF
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
SAN_SERVER_IP=$SAN_SERVER_IP
|
SERVER_IP=$SERVER_IP
|
||||||
source /nvram/san
|
source /nvram/san
|
||||||
disable_wd
|
disable_wd
|
||||||
#setup_network
|
#setup_network
|
||||||
|
|||||||
Reference in New Issue
Block a user