From da1bfe3c9caa34092b9832f3aaec33eef156ca36 Mon Sep 17 00:00:00 2001 From: Joseph Pan Date: Sat, 28 Oct 2017 18:45:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84launcher=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ingdang-AutoUpdate-Launcher-for-pi-User.sh | 33 ---------------- launcher/dingdang-Launcher.sh | 17 -------- ...h => dingdang-autoupdate-launcher-root.sh} | 18 ++++++--- launcher/dingdang-autoupdate-launcher-user.sh | 39 +++++++++++++++++++ launcher/dingdang-launcher-root.sh | 21 ++++++++++ launcher/dingdang-launcher-user.sh | 21 ++++++++++ 6 files changed, 93 insertions(+), 56 deletions(-) delete mode 100644 launcher/dingdang-AutoUpdate-Launcher-for-pi-User.sh delete mode 100644 launcher/dingdang-Launcher.sh rename launcher/{dingdang-AutoUpdate-Launcher-for-root-User.sh => dingdang-autoupdate-launcher-root.sh} (55%) mode change 100644 => 100755 create mode 100755 launcher/dingdang-autoupdate-launcher-user.sh create mode 100755 launcher/dingdang-launcher-root.sh create mode 100755 launcher/dingdang-launcher-user.sh diff --git a/launcher/dingdang-AutoUpdate-Launcher-for-pi-User.sh b/launcher/dingdang-AutoUpdate-Launcher-for-pi-User.sh deleted file mode 100644 index ae9452a..0000000 --- a/launcher/dingdang-AutoUpdate-Launcher-for-pi-User.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -sleep 1 - -#Delete Cache -sudo rm -r /home/pi/.cache -sudo rm -r /home/pi/.config -sudo rm -r /home/pi/.netease-musicbox -sudo rm -r /home/pi/userInfo -sleep 1 - -#AutoUpdate Before Launch -#Update dingdang-robot -cd /home/pi/dingdang -git pull - -#Update dingdang-contrib -cd /home/pi/.dingdang/contrib -git pull - -#Update dingdang-contrib Requirements -sudo pip install --upgrade -r requirements.txt -sleep 1 - -#Restore Configuration of AlsaMixer -alsactl --file=/home/pi/asound.state restore -sleep 1 - -#Launch Dingdang in LxTerminal -lxterminal -e "python /home/pi/dingdang/dingdang.py" -sleep 1 - -#Start Respeaker-Switcher in Background -sudo python /home/pi/ReSpeaker-Switcher/switcher.py & diff --git a/launcher/dingdang-Launcher.sh b/launcher/dingdang-Launcher.sh deleted file mode 100644 index 9c40b13..0000000 --- a/launcher/dingdang-Launcher.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -sleep 1 - -#Delete Cache -sudo rm -r /root/.cache -sudo rm -r /root/.config -sudo rm -r /root/.netease-musicbox -sudo rm -r /root/userInfo - -#Restore Configuration of AlsaMixer -alsactl --file=/home/pi/asound.state restore -sleep 1 - -#Start DingDang -sudo lxterminal -e "python /home/pi/dingdang/dingdang.py" -sleep 1 -sudo python /home/pi/ReSpeaker-Switcher/switcher.py & diff --git a/launcher/dingdang-AutoUpdate-Launcher-for-root-User.sh b/launcher/dingdang-autoupdate-launcher-root.sh old mode 100644 new mode 100755 similarity index 55% rename from launcher/dingdang-AutoUpdate-Launcher-for-root-User.sh rename to launcher/dingdang-autoupdate-launcher-root.sh index 7e17d72..863eabe --- a/launcher/dingdang-AutoUpdate-Launcher-for-root-User.sh +++ b/launcher/dingdang-autoupdate-launcher-root.sh @@ -1,9 +1,11 @@ #!/bin/bash sleep 1 +# tmux session name +session_name="dingdang" + #Delete Cache sudo rm -r /root/.cache -sudo rm -r /root/.config sudo rm -r /root/.netease-musicbox sudo rm -r /root/userInfo sleep 1 @@ -21,12 +23,16 @@ sudo pip install --upgrade -r requirements.txt sleep 1 #Restore Configuration of AlsaMixer -alsactl --file=/home/pi/asound.state restore -sleep 1 +if [ -f /home/pi/asound.state ]; then + alsactl --file=/home/pi/asound.state restore + sleep 1 +fi -#Launch Dingdang in LxTerminal -sudo lxterminal -e "python /home/pi/dingdang/dingdang.py" +#Launch Dingdang in tmux +sudo tmux new-session -d -s $session_name $HOME/dingdang/dingdang.py sleep 1 #Start Respeaker-Switcher in Background -sudo python /home/pi/ReSpeaker-Switcher/switcher.py & +if [ -d /home/pi/ReSpeaker-Switcher]; then + sudo python /home/pi/ReSpeaker-Switcher/switcher.py & +fi diff --git a/launcher/dingdang-autoupdate-launcher-user.sh b/launcher/dingdang-autoupdate-launcher-user.sh new file mode 100755 index 0000000..9d83008 --- /dev/null +++ b/launcher/dingdang-autoupdate-launcher-user.sh @@ -0,0 +1,39 @@ +#!/bin/bash +sleep 1 + +# tmux session name +session_name="dingdang" + +#Delete Cache +sudo rm -r $HOME/.cache +sudo rm -r $HOME/.netease-musicbox +sudo rm -r $HOME/userInfo +sleep 1 + +#AutoUpdate Before Launch +#Update dingdang-robot +cd $HOME/dingdang +git pull + +#Update dingdang-contrib +cd $HOME/.dingdang/contrib +git pull + +#Update dingdang-contrib Requirements +sudo pip install --upgrade -r requirements.txt +sleep 1 + +#Restore Configuration of AlsaMixer +if [ -f $HOME/asound.state ]; then + alsactl --file=$HOME/asound.state restore + sleep 1 +fi + +#Launch Dingdang in tmux +tmux new-session -d -s $session_name $HOME/dingdang/dingdang.py +sleep 1 + +#Start Respeaker-Switcher in Background +if [ -d $HOME/ReSpeaker-Switcher]; then + sudo python $HOME/ReSpeaker-Switcher/switcher.py & +fi diff --git a/launcher/dingdang-launcher-root.sh b/launcher/dingdang-launcher-root.sh new file mode 100755 index 0000000..49a48f1 --- /dev/null +++ b/launcher/dingdang-launcher-root.sh @@ -0,0 +1,21 @@ +#!/bin/bash +sleep 1 + +#Delete Cache +sudo rm -r /root/.cache +sudo rm -r /root/.netease-musicbox +sudo rm -r /root/userInfo + +#Restore Configuration of AlsaMixer +if [ -f /home/pi/asound.state ]; then + alsactl --file=/home/pi/asound.state restore + sleep 1 +fi + +#Start DingDang +sudo tmux new-session -d -s $session_name $HOME/dingdang/dingdang.py +sleep 1 + +if [ -d /home/pi/ReSpeaker-Switcher]; then + sudo python /home/pi/ReSpeaker-Switcher/switcher.py & +fi diff --git a/launcher/dingdang-launcher-user.sh b/launcher/dingdang-launcher-user.sh new file mode 100755 index 0000000..5a6526c --- /dev/null +++ b/launcher/dingdang-launcher-user.sh @@ -0,0 +1,21 @@ +#!/bin/bash +sleep 1 + +#Delete Cache +sudo rm -r /root/.cache +sudo rm -r /root/.netease-musicbox +sudo rm -r /root/userInfo + +#Restore Configuration of AlsaMixer +if [ -f /home/pi/asound.state ]; then + alsactl --file=/home/pi/asound.state restore + sleep 1 +fi + +#Start DingDang +tmux new-session -d -s $session_name $HOME/dingdang/dingdang.py +sleep 1 + +if [ -d /home/pi/ReSpeaker-Switcher]; then + sudo python /home/pi/ReSpeaker-Switcher/switcher.py & +fi