forked from axiom-team/astroport
Automatic nodename finding | lolcat
This commit is contained in:
parent
c666def88b
commit
70e5bfbfc4
|
@ -52,11 +52,13 @@ sudo cp -f /home/$YOU/.zen/astroport/.install/templates/copylaradio/mpd.conf /et
|
||||||
sudo sed -i "s/_USER_/$USER/g" /etc/mpd.conf || err=1
|
sudo sed -i "s/_USER_/$USER/g" /etc/mpd.conf || err=1
|
||||||
mkdir ~/.config/mpd && sudo cp -f /etc/mpd.conf ~/.config/mpd/mpd.conf && sudo chown $USER ~/.config/mpd/mpd.conf
|
mkdir ~/.config/mpd && sudo cp -f /etc/mpd.conf ~/.config/mpd/mpd.conf && sudo chown $USER ~/.config/mpd/mpd.conf
|
||||||
|
|
||||||
## MUSIC & PLAYLISTS
|
## VIDEO & AUDIO & PLAYLISTS ~/.zen/ DIR
|
||||||
mkdir -p ~/.zen/music
|
mkdir -p ~/.zen/video
|
||||||
|
mkdir -p ~/.zen/audio
|
||||||
mkdir -p ~/.zen/playlists
|
mkdir -p ~/.zen/playlists
|
||||||
|
|
||||||
## CHOWN mpd FILES STRUCTURE
|
## CHOWN mpd FILES STRUCTURE (
|
||||||
|
echo "TODO: CHECK if mpd start after a reboot !!"
|
||||||
sudo chown -R $USER /var/lib/mpd/ /var/run/mpd /run/mpd /var/log/mpd
|
sudo chown -R $USER /var/lib/mpd/ /var/run/mpd /run/mpd /var/log/mpd
|
||||||
sudo service mpd restart || err=1
|
sudo service mpd restart || err=1
|
||||||
## TODO add to system start (/etc/rc.local?)
|
## TODO add to system start (/etc/rc.local?)
|
||||||
|
@ -99,11 +101,30 @@ sudo rm -f /etc/nginx/sites-enabled/default
|
||||||
|
|
||||||
sudo systemctl restart nginx || err=1
|
sudo systemctl restart nginx || err=1
|
||||||
|
|
||||||
echo "Trying to REstart OASIS with good $nodename security options"
|
|
||||||
|
|
||||||
kill -9 $(ps auxf --sort=+utime | grep -w oasis | grep -v -E 'color=auto|grep' | tail -n 1 | awk '{print $2}')
|
kill -9 $(ps auxf --sort=+utime | grep -w oasis | grep -v -E 'color=auto|grep' | tail -n 1 | awk '{print $2}')
|
||||||
extension=$(echo $nodename | cut -d '.' -f 2)
|
echo "REstarting OASIS with good $nodename & network config"
|
||||||
|
[[ ! $(which nslookup) ]] && sudo apt-get install lolcat dnsutils -y
|
||||||
|
|
||||||
|
echo '
|
||||||
|
__ ___ _ ___
|
||||||
|
/ |/ /_ __ ____ ____ _____ ___ ___ (_)___/__ \
|
||||||
|
/ /|_/ / / / / / __ \/ __ `/ __ `__ \/ _ \ / / ___// _/
|
||||||
|
/ / / / /_/ / / / / / /_/ / / / / / / __/ / (__ )/_/
|
||||||
|
/_/ /_/\__, / /_/ /_/\__,_/_/ /_/ /_/\___/ /_/____/(_)
|
||||||
|
/____/
|
||||||
|
' | lolcat
|
||||||
|
|
||||||
myip=$(hostname -I | awk '{print $1}')
|
myip=$(hostname -I | awk '{print $1}')
|
||||||
|
# Check if IP is from reserved LAN addresses
|
||||||
isLAN=$(echo $myip | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
|
isLAN=$(echo $myip | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
|
||||||
|
# Find 1st route gateway
|
||||||
|
myRouter=$(sudo route -n | head -n 3 | tail -n 1 | awk '{print $2}')
|
||||||
|
# Ask to the router its name (BOX DNS or system defined)
|
||||||
|
[[ $isLAN ]] && nodename=$(sudo nslookup $myip $myRouter | head -n 1 | awk -F ' = ' '{print $2}' | sed 's/\.[^.]*$//') \
|
||||||
|
|| nodename=$(sudo nslookup $myip | head -n 1 | awk -F ' = ' '{print $2}' | sed 's/\.[^.]*$//')
|
||||||
|
echo $nodename
|
||||||
|
|
||||||
if [[ ! $isLAN ]]; then
|
if [[ ! $isLAN ]]; then
|
||||||
oasis --allow-host $nodename 2>&1>/dev/null &
|
oasis --allow-host $nodename 2>&1>/dev/null &
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
music_directory "/home/_USER_/.zen/music"
|
music_directory "/home/_USER_/.zen/audio"
|
||||||
playlist_directory "/home/_USER_/.zen/playlists"
|
playlist_directory "/home/_USER_/.zen/playlists"
|
||||||
user "_USER_"
|
user "_USER_"
|
||||||
bind_to_address "localhost"
|
bind_to_address "localhost"
|
||||||
|
|
Loading…
Reference in New Issue