Use BASH new-style variable references

This commit is contained in:
Joshua Boniface 2017-03-31 05:55:20 +00:00
parent e14027e971
commit 4cff7316af
1 changed files with 11 additions and 13 deletions

24
bmc.sh
View File

@ -31,12 +31,12 @@ bmcinfo() {
echo -e " BMC temperature: $( sudo /opt/vc/bin/vcgencmd measure_temp | awk -F'=' '{ print $2 }' )" echo -e " BMC temperature: $( sudo /opt/vc/bin/vcgencmd measure_temp | awk -F'=' '{ print $2 }' )"
} }
sethostname() { sethostname() {
newhostname="$1" newhostname="${1}"
echo "Setting hostname to '$newhostname'." echo "Setting hostname to '${newhostname}'."
sudo sed -i '/^127.0.1.1/d' /etc/hosts &>/dev/null sudo sed -i '/^127.0.1.1/d' /etc/hosts &>/dev/null
sudo tee -a /etc/hosts <<<"127.0.1.1 $newhostname" &>/dev/null sudo tee -a /etc/hosts <<<"127.0.1.1 ${newhostname}" &>/dev/null
sudo hostname $newhostname &>/dev/null sudo hostname ${newhostname} &>/dev/null
sudo tee /etc/hostname <<<"$newhostname" &>/dev/null sudo tee /etc/hostname <<<"${newhostname}" &>/dev/null
} }
sethost() { sethost() {
newbmcname="${1}" newbmcname="${1}"
@ -44,7 +44,7 @@ sethost() {
sudo tee /etc/bmcname <<<"${newbmcname}" &>/dev/null sudo tee /etc/bmcname <<<"${newbmcname}" &>/dev/null
} }
setpassword() { setpassword() {
password="$1" password="${1}"
echo "Setting BMC password." echo "Setting BMC password."
sudo chpasswd <<<"bmc:${password}" sudo chpasswd <<<"bmc:${password}"
} }
@ -86,7 +86,7 @@ echo -e "| Raspberry Pi BMC |"
echo -e "--------------------" echo -e "--------------------"
echo echo
echo -e "Host system: \e[1m${hostsystem}\e[0m" echo -e "Host system: \e[1m${hostsystem}\e[0m"
echo -e "Host state: $powerstate" echo -e "Host state: ${powerstate}"
echo echo
help help
echo echo
@ -95,10 +95,10 @@ stty eof undef
stty intr undef stty intr undef
echo -en "\e[1m\e[34m[$(hostname)]>\e[0m " echo -en "\e[1m\e[34m[$(hostname)]>\e[0m "
read input read input
case $input in case ${input} in
'state') 'state')
readpower readpower
echo -e "Host state: $powerstate" echo -e "Host state: ${powerstate}"
echo echo
;; ;;
'console') 'console')
@ -112,19 +112,17 @@ case $input in
'power') 'power')
powersw_press powersw_press
readpower readpower
echo -e "Host state: $powerstate" echo -e "Host state: ${powerstate}"
echo echo
;; ;;
'reset') 'reset')
resetsw_press resetsw_press
readpower
echo -e "Host state: $powerstate"
echo echo
;; ;;
'kill') 'kill')
powersw_hold powersw_hold
readpower readpower
echo -e "Host state: $powerstate" echo -e "Host state: ${powerstate}"
echo echo
;; ;;
'locate') 'locate')