update script, daemon, services, added sound, small improvements

This commit is contained in:
Lurkars 2022-02-08 20:09:26 +01:00
parent 5fdc7d636b
commit c769724146
14 changed files with 671 additions and 433 deletions

410
README.md
View File

@ -1,29 +1,30 @@
# luniebox
lunibox is a RFID jukebox based on a Raspberry Pi. It is similar to the [Phoniebox](https://www.phoniebox.de) \[[https://github.com/MiczFlor/RPi-Jukebox-RFID](GitHub)\] and an upgrade of the [TonUINO (de)](https://www.voss.earth/tonuino/) which both are DIY versions of the popular Toniebox©. The main focus for now is to play Spotify© content and playing local files (also supports Spotify© download for offline use). Other sources will be integrated later.
lunibox is a RFID jukebox based on a Raspberry Pi. It is similar to the [Phoniebox](https://www.phoniebox.de) \[[GitHub](https://github.com/MiczFlor/RPi-Jukebox-RFID)\] and an upgrade of the [TonUINO (de)](https://www.voss.earth/tonuino/) which both are DIY versions of the popular Toniebox©. The main focus for now is to play Spotify© content and playing local files (also supports Spotify© download for offline use). Other sources will be integrated later.
## Prerequisites
You need to be familiar with ssh (Putty on Windows). For the usage of Spotify© a premium account is required.
### Hardware
- Raspberry Pi (tested with Raspberry Pi 3 Model B, Zero W, Zero 2 W) \[starting at ~14€\]
- Raspberry Pi (tested with Raspberry Pi 3 Model B, Zero 2 W) \[starting at ~14€\]
- power supply (5V ~2.5A) \[starting at ~6€\]
- Micro SD card (at least 4GB) \[starting at ~4€\]
- RC522 RFID Reader connected to [TODO] \[starting at ~1.50€\]
- RC522 RFID Reader \[starting at ~1.50€\]
- RFID (MiFare) cards or chips \[starting at ~2€\]
- a Audio Card:
- Pimoroni Audio Amp SHIM (3W Mono Amp) \[starting at ~11€\] with passive speaker \[starting at ~5€\]
- Pimoroni Audio DAC SHIM \[starting at ~14€\] with active speaker
- Adafruit Speaker Bonnet for Raspberry Pi
- ...something else (use custom setup!)
- (optional) MPU9250 9-axis sensor [TODO] \[starting at ~1.50€\]
- (optional) 2x Push Buttons for volume control \[starting at ~1€\]
- (optional) MPU9250 9-axis sensor \[starting at ~1.50€\]
- (optional) Waveshare UPS HAT + 2x 18650 18650 Li battery \[starting at ~30€\]
- some wires or dupont connectors \[starting at ~2€\]
- case for all above
- depending on hardware: soldering equipment
A minimal setup (Raspberry Zero 2 W, power supply, Micro SD, RC522, Cards, Audio Amp) should be about ~40€ plus case materials.
A minimal setup (Raspberry Zero 2 W, power supply, Micro SD, RC522, Cards, Audio Amp, Speaker, Buttons) should be about ~45€ plus case materials.
### Software
- latest Raspberry Pi OS blank installation on Micro SD card (Instructions: [raspberrypi.com/software/](https://www.raspberrypi.com/software/))
@ -36,209 +37,278 @@ If you're using a Raspberry Pi Zero or have missing peripherals to setup WiFi an
- insert Micro SD card with Raspberry Pi OS into a computer
- place an empty file called `ssh` into `/boot` folder/partioon
- place a filed called `wpa_supplicant.conf` into `/boot` folder/partition with following content
```
country=$COUNTRY_CODE
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="$WIFI_SSID"
psk="$WIFI_PASSWORD"
}
```
> ```
> country=$COUNTRY_CODE
> ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
> update_config=1
>
> network={
> ssid="$WIFI_SSID"
> psk="$WIFI_PASSWORD"
> }
> ```
- replace `$COUNTRY_CODE` with upper-case country code (eg. GB or DE) and `$WIFI_SSID` and `$WIFI_PASSWORD` with your WiFi credentials
- plug card back into your Pi and connect power supply
## Setup
Establish a ssh connection to your Pi:
Open terminal on your pi or establish a ssh connection to your Pi:
- the Pi should be reachable under `raspberrypi` or `raspberrypi.local` in your network, if not try to find out it's IP address from your router.
- default username is `pi` and default password is `raspberry`
- Example: `ssh pi@raspberrypi.local` or `ssh pi@192.168.2.100`
> ⚠️ Warning: you should change the default password by executing `passwd` after login
> **⚠️ Warning: you should change the default password by executing `passwd` after login**
### Automatic setup
> ⚠️ Warning: executing scripts from the internet without checking is bad. This is only done to get things done fast. In any doubts you can perform the [Manual setup](#manual-setup) and execute all commands step-by-step to understand what's going on.
> **⚠️ Warning: executing scripts from the internet without checking is bad. This is only done to get things done fast. In any doubts you can perform the [Manual setup](#manual-setup) and execute all commands step-by-step to understand what's going on.**
- download and excecute setup script (you will be prompted to confirm certain steps beforehand anyway)
> `curl https://git.bstly.de/Lurkars/luniebox/raw/branch/main/luniebox.sh -o luniebox.sh`
>
> `chmod +x luniebox.sh`
>
> `./luniebox.sh`
```
bash <(curl -s https://git.bstly.de/Lurkars/luniebox/raw/branch/main/luniebox.sh)
```
- Alternative first download script, take a look and then execute
```
curl https://git.bstly.de/Lurkars/luniebox/raw/branch/main/luniebox.sh -o luniebox.sh
chmod +x luniebox.sh
./luniebox.sh
```
### Manual setup
#### Software setup
go to home directory
> `cd /home/pi`
- go to home directory
```
cd /home/pi
```
install `git`, `python3-venv` and `python3-pip`
> `sudo apt install -y git python3-venv python3-pip`
- install `git`, `python3-venv` and `python3-pip`
```
sudo apt install -y git python3-venv python3-pip
```
clone repository `https://git.bstly.de/Lurkars/luniebox.git` with sources and config:
> `git clone https://git.bstly.de/Lurkars/luniebox.git luniebox`
- clone repository `https://git.bstly.de/Lurkars/luniebox.git` with sources and config:
```
git clone https://git.bstly.de/Lurkars/luniebox.git luniebox
```
setup application
> `cd /home/pi/luniebox/application`
>
> `python -m venv venv`
>
> `source venv/bin/activate`
>
> `export CFLAGS=-fcommon`
>
> `pip install -r requirements.txt`
>
> `deactivate`
>
> `mkdir /home/pi/luniebox/config`
>
> `cp /home/pi/luniebox/contrib/config/luniebox.cfg /home/pi/luniebox/config/luniebox.cfg`
>
> `sudo cp /home/pi/luniebox/contrib/service/luniebox-app.service /etc/systemd/system/`
>
> `sudo cp /home/pi/luniebox/contrib/service/luniebox-daemon.service /etc/systemd/system/`
>
> `sudo systemctl daemon-reload`
>
> `sudo systemctl enable luniebox-app luniebox-daemon`
##### Setup luniebox application and daemon
- setup application by building python venv and setup systemd service
```
cd /home/pi/luniebox/application
python -m venv venv
source venv/bin/activate
export CFLAGS=-fcommon
pip install -r requirements.txt
deactivate
mkdir /home/pi/luniebox/config
cp /home/pi/luniebox/contrib/config/luniebox.cfg /home/pi/luniebox/config/luniebox.cfg
sudo cp /home/pi/luniebox/contrib/service/luniebox-app.service /etc/systemd/system/
sudo cp /home/pi/luniebox/contrib/service/luniebox-daemon.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable luniebox-app luniebox-daemon
```
##### Setup spotify
setup spotifyd
> `mkdir /home/pi/luniebox/bin`
>
> `wget -c https://github.com/Spotifyd/spotifyd/releases/download/v0.3.3/spotifyd-linux-armv6-slim.tar.gz -O - | tar -xz -C /home/pi/luniebox/bin`
>
> `cp /home/pi/luniebox/contrib/config/spotifyd.cfg /home/pi/luniebox/config/spotifyd.cfg` (if you use other audio hardware, you may need to adjust the `backend` and `device` properties to your needs!)
>
> `sudo cp /home/pi/luniebox/contrib/service/spotifyd.service /etc/systemd/system/`
>
> `sudo systemctl daemon-reload`
>
> `sudo systemctl enable spotifyd`
For Spotify support, spofiyd is required.
setup mpd
> `mkdir /home/pi/luniebox/library`
>
> `sudo apt install -y mpd`
>
> `sudo cp /home/pi/luniebox/contrib/config/mpd.conf /etc/mpd.conf` (if you use other audio hardware, you may need to adjust the `audio_output` section to your needs!)
>
- get spotifyd binary and setup systemd service
```
mkdir /home/pi/luniebox/bin`
wget -c https://github.com/Spotifyd/spotifyd/releases/download/v0.3.3/spotifyd-linux-armv6-slim.tar.gz -O - | tar -xz -C /home/pi/luniebox/bin
cp /home/pi/luniebox/contrib/config/spotifyd.cfg /home/pi/luniebox/config/spotifyd.cfg
sudo cp /home/pi/luniebox/contrib/service/spotifyd.service /etc/systemd/system/`
sudo systemctl daemon-reload`
sudo systemctl enable spotifyd
```
setup ClSpotify
> `git clone https://github.com/agent255/clspotify.git /home/pi/clspotify`
>
> `cd /home/pi/clspotify`
>
> `python -m venv venv`
>
> `source venv/bin/activate`
>
> `pip install -r requirements.txt`
>
> `deactivate`
>
> `sed -i "s/^zspotify_path =.*$/zspotify_path = \/home\/pi\/clspotify\//" /home/pi/luniebox/config/luniebox.cfg`
> If you use other audio hardware, you may need to adjust the `backend` and `device` property in `/home/pi/luniebox/config/spotifyd.cfg` to your needs!
start/restart all services
> `sudo systemctl restart mpd spotifyd luniebox-daemon luniebox-app`
##### Setup Music Player Daemon
for offline file support setup [Music Player Daemon](https://www.musicpd.org/) (mpd)
- create library folder and install `mpd`
```
mkdir /home/pi/luniebox/library
sudo apt install -y mpd
sudo cp /home/pi/luniebox/contrib/config/mpd.conf /etc/mpd.conf
```
> If you use other audio hardware, you may need to adjust the `audio_output` in `/etc/mpc.conf` section to your needs!
##### Setup ClSpotify
for Spotify offline support setup [ClSpotify](https://github.com/agent255/clspotify.git) (requires [spotify](#setup-spotify) and [mpd](#setup-music-player-daemon)!).
- get code, install pythen venv and update config
```
git clone https://github.com/agent255/clspotify.git /home/pi/clspotify
cd /home/pi/clspotify
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
deactivate
sed -i "s/^zspotify_path =.*$/zspotify_path = \/home\/pi\/clspotify\//" /home/pi/luniebox/config/luniebox.cfg
```
#### Hardware Setup
##### enable SPI for RFID Reader
For a detailed Raspberry Pi pinout take a look at [https://pinout.xyz](https://pinout.xyz).
uncomment `dtparam=spi=on` in `/boot/config.txt`
> `sudo sed -i "/dtparam=spi=on/s/^#//g" /boot/config.txt`
##### Setup RC522 RFID Reader
##### enable I2C for MPU9250 9-axis sensor
- uncomment `dtparam=spi=on` in `/boot/config.txt` tp enable SPI for RC522
```
sudo sed -i "/dtparam=spi=on/s/^#//g" /boot/config.txt
```
install `i2c-tools` and `python3-smbus`
> `sudo apt install -y i2c-tools python3-smbus`
- connect RC522
- SDA to Pin 24 \[GPIO 8 / SPI0 CE0\]
- SCK to Pin 23 \[GPIO 11 / SPI0 SCLK / CLK\]
- MOSI to Pin 19 \[GPIO 10 / SPI0 MOSI\]
- MISO to Pin 21 \[GPIO 9 / SPI0 MISO\]
- GND to Pin 20 \[Ground\]
- RST to Pin 22 \[GPIO 25\]
- 3.3v to Pin 1 \[3v3 Power\]
uncomment `dtparam=i2c_arm=on` in `/boot/config.txt`
> `sudo sed -i "/dtparam=i2c_arm=on/s/^#//g" /boot/config.txt`
##### Setup Pimoroni Amp or DAC
- disable onboard audio comment out `dtparam=audio=on` in `/boot/config.txt`
```
sudo sed -i "/dtparam=audio=on/s/^/#/g" /boot/config.txt
```
- setup hifiberry-dac by adding following content to `/boot/config.txt`
> ```
> # setup hifiberry for Pimoroni Shim
> dtoverlay=hifiberry-dac
> gpio=25=op,dh
> ```
```
printf "\n# setup hifiberry for Pimoroni Shim\ndtoverlay=hifiberry-dac\ngpio=25=op,dh\n" | sudo tee -a /boot/config.txt
```
##### Setup Adafruit Speaker Bonnet for Raspberry Pi
- disable onboard audio comment out `dtparam=audio=on` in `/boot/config.txt`
```
sudo sed -i "/dtparam=audio=on/s/^/#/g" /boot/config.txt
```
- setup hifiberry-dac and i2s by adding following content to `/boot/config.txt`
> ```
> # setup hifiberry and i2s for Adafruit Speaker Bonnet
> dtoverlay=hifiberry-dac
> dtoverlay=i2s-mmap
> ```
```
printf "\n# setup hifiberry and i2s for Adafruit Speaker Bonnet\ndtoverlay=hifiberry-dac\ndtoverlay=i2s-mmap\n" | sudo tee -a /boot/config.txt
```
- copy [contrib/config/asound.conf](contrib/config/asound.conf) to `/etc/asound.conf`.
```
cat /home/pi/luniebox/contrib/config/asound.conf | sudo tee /etc/asound.conf
```
- copy [contrib/config/.asoundrc](contrib/config/.asoundrc) to `/home/pi/.asoundrc`.
```
cat /home/pi/luniebox/contrib/config/.asoundrc | tee /home/pi/.asoundrc
```
##### Setup Push Buttons
- connect first push button (volume down)
1. Pin 8 \[GPIO 14\]
2. Pin 6 \[Ground\]
- connect second push button (volume up)
1. Pin 7 \[GPIO 4\]
2. Pin 9 \[Ground\]
##### Setup MPU9250 9-axis sensor
- install `i2c-tools` and `python3-smbus`
```
sudo apt install -y i2c-tools python3-smbus
```
- uncomment `dtparam=i2c_arm=on` in `/boot/config.txt` to enable I2C for MPU9250
```
sudo sed -i "/dtparam=i2c_arm=on/s/^#//g" /boot/config.txt
```
- setup i2c bus 4 for MPU9250 by adding following content to `/boot/config.txt`
> ```
> # setup ic2 bus 4 for mpu
> dtoverlay=i2c-gpio,bus=4,i2c_gpio_delay_us=1,i2c_gpio_sda=23,i2c_gpio_scl=24
> ```
```
printf "\n# setup i2c bus 4 for mpu\ndtoverlay=i2c-gpio,bus=4,i2c_gpio_delay_us=1,i2c_gpio_sda=23,i2c_gpio_scl=24\n" | sudo tee -a /boot/config.txt
```
- connect MPU9250
- SDA to Pin 16 \[GPIO 23\]
- SCL to Pin 18 \[GPIO 24\]
- GND to Pin 14 \[Ground\]
- 3V3 to Pin 17 \[3v3 Power\]
add `dtoverlay=i2c-gpio,bus=4,i2c_gpio_delay_us=1,i2c_gpio_sda=23,i2c_gpio_scl=24` to `/boot/config.txt`
> `printf "dtoverlay=i2c-gpio,bus=4,i2c_gpio_delay_us=1,i2c_gpio_sda=23,i2c_gpio_scl=24" | sudo tee -a /boot/config.txt`
#### Setup Audio
##### for Pimoroni Amp or DAC
disable onboard audio comment out `dtparam=audio=on` in `/boot/config.txt`
> `sudo sed -i "/dtparam=audio=on/s/^/#/g" /boot/config.txt`
setup hifiberry-dac by adding
```
dtoverlay=hifiberry-dac
gpio=25=op,dh
```
to `/boot/config.txt`
> `printf "dtoverlay=hifiberry-dac\ngpio=25=op,dh" | sudo tee -a /boot/config.txt`
##### for Adafruit Speaker Bonnet for Raspberry Pi
disable onboard audio comment out `dtparam=audio=on` in `/boot/config.txt`
> `sudo sed -i "/dtparam=audio=on/s/^/#/g" /boot/config.txt`
setup hifiberry-dac and i2s by adding
```
dtoverlay=hifiberry-dac
dtoverlay=i2s-mmap
```
to `/boot/config.txt`
> `printf "dtoverlay=hifiberry-dac\ndtoverlay=i2s-mmap" | sudo tee -a /boot/config.txt`
create `/etc/asound.conf` file with following content:
```
pcm.speakerbonnet {
type hw card 0
}
pcm.dmixer {
type dmix
ipc_key 1024
ipc_perm 0666
slave {
pcm "speakerbonnet"
period_time 0
period_size 1024
buffer_size 8192
rate 44100
channels 2
}
}
ctl.dmixer {
type hw card 0
}
pcm.softvol {
type softvol
slave.pcm "dmixer"
control.name "PCM"
control.card 0
}
ctl.softvol {
type hw card 0
}
pcm.!default {
type plug
slave.pcm "softvol"
}
```
After setup, reboot system.
> `sudo reboot`
#### Finish Setup
- After setup, reboot system.
```
sudo reboot
```
## Planned features
- status LEDs
- indicators for UPS HAT
- WiFi Hotspot (https://www.raspberryconnect.com/projects/65-raspberrypi-hotspot-accesspoints/158-raspberry-pi-auto-wifi-hotspot-switch-direct-connection)
- WiFi Hotspot (https://www.raspberryconnect.com/projects/65-raspberrypi-hotspot-accesspoints/158-raspberry-pi-auto-wifi-hotspot-switch-direct-connection)

View File

@ -10,18 +10,6 @@ app = Flask(__name__)
app.register_blueprint(api, url_prefix='/api')
app.register_blueprint(pages)
loglevel = 'INFO'
if luniebox.get_setting('logging', 'level'):
loglevel = luniebox.get_setting('logging', 'level')
logger = logging.getLogger('luniebox')
logger.setLevel(logging._nameToLevel[loglevel])
logFormatter = logging.Formatter(
style='{', datefmt='%Y-%m-%d %H:%M:%S', fmt='{asctime} {levelname}: {message}')
logstdoutHandler = logging.StreamHandler(sys.stdout)
logstdoutHandler.setFormatter(logFormatter)
logger.addHandler(logstdoutHandler)
if __name__ != '__main__':
gunicorn_logger = logging.getLogger('gunicorn.error')
app.logger.handlers = gunicorn_logger.handlers

View File

@ -3,6 +3,7 @@
import signal
import time
import sys
import subprocess
import logging
from luniebox import luniebox
import RPi.GPIO as GPIO
@ -26,23 +27,29 @@ class LunieboxDaemon(object):
self.tolerance = self.luniebox.get_setting(
'rfid', 'pause_tolerance', 4)
self.reads = 0
self.error_text = False
if self.luniebox.get_setting('hardware', 'mpu') == 'True':
self.mpu = MPU9250(
address_ak=AK8963_ADDRESS,
address_mpu_master=MPU9050_ADDRESS_68,
address_mpu_slave=None,
bus=4,
gfs=GFS_1000,
afs=AFS_8G,
mfs=AK8963_BIT_16,
mode=AK8963_MODE_C100HZ)
self.mpu.configure()
try:
self.mpu = MPU9250(
address_ak=AK8963_ADDRESS,
address_mpu_master=MPU9050_ADDRESS_68,
address_mpu_slave=None,
bus=4,
gfs=GFS_1000,
afs=AFS_8G,
mfs=AK8963_BIT_16,
mode=AK8963_MODE_C100HZ)
self.mpu.configure()
except Exception as exception:
logging.getLogger('luniebox').warning(
"Could not setup MPU9250: " + str(exception))
self.mpu = False
else:
self.mpu = False
def run(self):
logging.getLogger('luniebox').info("run luniebox")
logging.getLogger('luniebox').info("run luniebox daemon")
while True:
# mpu
@ -86,10 +93,14 @@ class LunieboxDaemon(object):
if self.reads >= self.tolerance:
self.reads = 0
self.luniebox.pause()
self.error_text = False
time.sleep(0.1)
else:
self.reads = 0
self.luniebox.play(text)
if text != self.error_text and not self.luniebox.play(text):
if self.luniebox.get_setting('luniebox', 'error_sound') != 'False':
self.error_text = text
self.error_sound()
time.sleep(0.1)
def signal_handler(self, signal, frame):
@ -98,6 +109,21 @@ class LunieboxDaemon(object):
luniebox.stop()
sys.exit(0)
def beep_sound(self):
self.play_sound("/home/pi/luniebox/audio/beep.wav",
str(self.luniebox.volume))
def error_sound(self):
self.play_sound("/home/pi/luniebox/audio/error.wav", "100")
def play_sound(self, path, volume):
volume_p = subprocess.Popen(
["amixer", "set", "PCM", volume + "%"], stdin=None,
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, close_fds=True, shell=False, group="pi", user="pi")
volume_p.wait()
subprocess.Popen(["aplay", path], stdin=None,
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, close_fds=True, shell=False, group="pi", user="pi")
if __name__ == "__main__":
daemon = LunieboxDaemon(luniebox=luniebox)

View File

@ -168,9 +168,9 @@ class Luniebox(object):
self.zspotify_path, username, password, root)
logging.getLogger('luniebox').info("spotifydl enabled!")
return True
except Exception as ex:
except Exception as exception:
logging.getLogger('luniebox').warning(
"error on setup spotifydl: " + str(ex))
"error on setup spotifydl: " + str(exception))
return False
def read_config(self):
@ -315,14 +315,20 @@ class Luniebox(object):
else:
logging.getLogger('luniebox').warn(
"cannot resume spotify: " + self.current)
return True
elif self.service == PlayerService.MPD:
if text != self.current:
if self.mpd_connect():
self.mpd.setvol(self.volume)
self.mpd.clear()
text = text.replace('mpd:', '')
self.mpd.add(text)
self.mpd.play()
try:
self.mpd.setvol(self.volume)
self.mpd.clear()
text = text.replace('mpd:', '')
self.mpd.add(text)
self.mpd.play()
except Exception as exception:
logging.getLogger('luniebox').warning(
"cannot not play mpd '" + text + "': " + str(exception))
return False
self.current = text
self.set_setting('luniebox', 'current', self.current)
self.resume = False
@ -334,8 +340,13 @@ class Luniebox(object):
"play mpd: " + self.current)
elif self.resume and text == self.current:
if self.mpd_connect():
self.mpd.setvol(self.volume)
self.mpd.play()
try:
self.mpd.setvol(self.volume)
self.mpd.play()
except Exception as exception:
logging.getLogger('luniebox').warning(
"cannot not resume mpd '" + self.current + "': " + str(exception))
return False
self.resume = False
if text.startswith('spotify:'):
logging.getLogger('luniebox').debug(
@ -343,10 +354,12 @@ class Luniebox(object):
else:
logging.getLogger('luniebox').debug(
"resume mpd: " + self.current)
elif text != None:
logging.getLogger('luniebox').info(
"invalid value(?): " + str(text))
return True
elif text != None:
logging.getLogger('luniebox').info(
"invalid value(?): " + str(text))
return False
return False
def stop(self):
self.pause()

View File

@ -6,4 +6,5 @@ mpu9250-jmdev==1.0.12
python-dateutil==2.8.2
python-mpd2==3.0.4
requests==2.26.0
smbus==1.1.post2
smbus2==0.4.1

BIN
audio/beep.wav Normal file

Binary file not shown.

BIN
audio/error.wav Normal file

Binary file not shown.

37
contrib/config/.asoundrc Normal file
View File

@ -0,0 +1,37 @@
pcm.speakerbonnet {
type hw card 0
}
pcm.dmixer {
type dmix
ipc_key 1024
ipc_perm 0666
slave {
pcm "speakerbonnet"
period_time 0
period_size 1024
buffer_size 8192
rate 44100
channels 2
}
}
ctl.dmixer {
type hw card 0
}
pcm.softvol {
type softvol
slave.pcm "dmixer"
control.name "PCM"
control.card 0
}
ctl.softvol {
type hw card 0
}
pcm.!default {
type plug
slave.pcm "softvol"
}

View File

@ -1,38 +1,26 @@
pcm.speakerbonnet {
type hw card 0
type hw card 0
}
pcm.dmixer {
type dmix
ipc_key 1024
ipc_perm 0666
slave {
pcm "speakerbonnet"
period_time 0
period_size 1024
buffer_size 8192
rate 44100
channels 2
}
pcm.!default {
type plug
slave.pcm "dmixer"
}
ctl.dmixer {
type hw card 0
pcm.dmixer {
type dmix
ipc_key 1024
ipc_perm 0666
slave {
pcm "speakerbonnet"
period_time 0
period_size 1024
buffer_size 8192
rate 44100
channels 2
}
}
pcm.softvol {
type softvol
slave.pcm "dmixer"
control.name "PCM"
control.card 0
}
ctl.softvol {
type hw card 0
}
pcm.!default {
type plug
slave.pcm "softvol"
}
ctl.dmixer {
type hw card 0
}

View File

@ -13,5 +13,5 @@ level = DEBUG
library_path = /home/pi/luniebox/library
[spotify]
auto_download = False
auto_download = True
zspotify_path =

View File

@ -2,11 +2,10 @@
Description=Luniebox Application
[Service]
Type=simple
WorkingDirectory=/home/pi/luniebox/application
ExecStart=/home/pi/luniebox/application/venv/bin/gunicorn -b 0.0.0.0:80 app:app
Restart=always
RestartSec=12
Restart=on-failure
RestartSec=15
[Install]
WantedBy=multi-user.target

View File

@ -2,11 +2,13 @@
Description=Luniebox Daemon
[Service]
Type=simple
User=pi
Group=pi
WorkingDirectory=/home/pi/luniebox/application
ExecStart=/home/pi/luniebox/application/venv/bin/python daemon.py
Restart=always
RestartSec=12
Restart=on-failure
RestartSec=15
#FailureAction=/home/pi/luniebox/application/venv/bin/python daemon-failure.py
[Install]
WantedBy=multi-user.target

View File

@ -9,8 +9,8 @@ After=network-online.target
User=pi
Group=pi
ExecStart=/home/pi/luniebox/bin/spotifyd --config-path /home/pi/luniebox/config/spotifyd.cfg --no-daemon
Restart=always
RestartSec=12
Restart=on-failure
RestartSec=15
[Install]
WantedBy=multi-user.target

View File

@ -1,19 +1,22 @@
#!/usr/bin/env bash
INSTALL_CONFIG_FILE="/home/pi/luniebox/config/install.cfg"
REPO_URL="https://git.bstly.de/Lurkars/luniebox.git"
AUTOMATIC=false
NO_UPDATES=false
NO_SPOTIFYDL=false
NO_SPOTIFY=false
NO_MPD=false
NO_AUDIO=false
MPU=false
NO_MPU=true
AUDIO_DEVICE=false
AUDIO_DEVICES=("pimoroni" "adafruit")
DEVICE_NAME=false
REBOOT=false
help() {
local IFS="|"
printf "Usage: ${SCRIPTNAME} [-h] [-a] [--audio-device AUDIO_DEVICE] [--device-name DEVICE_NAME] [--no-updates] [--no-spotifydl] [--no-spotify] [--no-mpd] [--mpu] \n"
printf "Usage: ${SCRIPTNAME} [-h] [-a] [--audio-device AUDIO_DEVICE] [--device-name DEVICE_NAME] [--no-updates] [--no-spotifydl] [--no-spotify] [--no-mpd] [--mpu] [--repo-url] \n"
printf " -h\t\t\t\tshow this help\n"
printf " -a\t\t\t\tautomatic/non-interactive mode (without --audio-device, no Audio device is set up)\n"
printf " --audio-device [AUDIO_DEVICE]\tset Audio device (one of [${AUDIO_DEVICES[*]}])\n"
@ -23,6 +26,7 @@ help() {
printf " --no-mpd\t\t\tskip installation of Music Player Daemon (no offline support, also skips zspotify)\n"
printf " --no-spotify\t\t\tskip installation of spotifyd (no Spotify support, also skips zspotify)\n"
printf " --mpu\t\t\t\tsetup MPU9250 on I2C port (default is no MPU9250)\n"
printf " --repo-url [REPOSITORY_URL]\tset luniebox repository url (default https://git.bstly.de/Lurkars/luniebox.git)\n"
exit 0
}
@ -55,7 +59,11 @@ while [ -n "$1" ]; do
shift
;;
"--mpu")
MPU=true
NO_MPU=false
;;
"--repo-url")
REPO_URL="$2"
shift
;;
*)
printf "\nargument '$1' not supported!\n\n"
@ -106,248 +114,354 @@ Run the script with -h to get more information about possible options to be appl
setup() {
cd /home/pi
if [[ ${NO_UPDATES} == "false" ]]; then
update
fi
initialize
update
setup_device_name
setup_software
set_device_name
setup_rfid
setup_audio
setup_mpu
if [[ ${NO_AUDIO} == "false" ]]; then
setup_audio
fi
finalize
}
update() {
if [[ ${AUTOMATIC} == "false" ]]; then
read -rp "Do you want to update system now? [Y/n] (recommended) " response
echo ""
case "$response" in
[nN][oO] | [nN])
return 0
;;
esac
initialize() {
echo "Initizalize setup..."
echo "Check for previous setup..."
if [[ -f "${INSTALL_CONFIG_FILE}" ]]; then
eval $(sed -r "/[^=]+=[^=]+/!d;s/\s+=\s/=/g" "${INSTALL_CONFIG_FILE}")
fi
echo "Update system"
sudo apt update
sudo apt upgrade -y
if [[ -z ${SETUP_INITIALIZE+x} ]]; then
echo "Install required packages..."
sudo apt install -y git
echo "Fetch luniebox repository..."
git clone "${REPO_URL}" /home/pi/luniebox
echo "Create config directory"
mkdir -p /home/pi/luniebox/config
echo "SETUP_INITIALIZE=true" | tee -a "${INSTALL_CONFIG_FILE}" 1>/dev/null
else
echo "luniebox is already setup!"
fi
if [[ -z ${SETUP_REPO_URL+x} ]]; then
echo "SETUP_REPO_URL=${REPO_URL}" | tee -a "${INSTALL_CONFIG_FILE}" 1>/dev/null
else
REPO_URL="${SETUP_REPO_URL}"
fi
}
update() {
if [[ -z ${SETUP_UPDATES+x} ]]; then
if [[ ${NO_UPDATES} == "false" ]]; then
if [[ ${AUTOMATIC} == "false" ]]; then
read -rp "Do you want to update system now? [Y/n] (recommended) " response
echo ""
case "$response" in
[nN][oO] | [nN])
NO_UPDATES=true
return 0
;;
esac
fi
echo "Update system"
sudo apt update
sudo apt upgrade -y
echo "SETUP_UPDATES=true" | tee -a "${INSTALL_CONFIG_FILE}" 1>/dev/null
fi
fi
if [[ -z ${SETUP_NO_UPDATES+x} ]]; then
echo "SETUP_NO_UPDATES=${NO_UPDATES}" | tee -a "${INSTALL_CONFIG_FILE}" 1>/dev/null
else
NO_UPDATES="${SETUP_NO_UPDATES}"
fi
}
setup_software() {
setup_app
if [[ ${NO_SPOTIFY} == "false" ]]; then
setup_spotify
fi
if [[ ${NO_MPD} == "false" ]]; then
setup_mpd
fi
if [[ ${NO_SPOTIFYDL} == "false" ]]; then
setup_zspotify
fi
setup_spotify
setup_mpd
setup_zspotify
}
setup_app() {
echo "Install required packages..."
sudo apt install -y git python3-venv python3-pip
echo "Fetch luniebox repository..."
git clone https://git.bstly.de/Lurkars/luniebox.git /home/pi/luniebox
cd /home/pi/luniebox/application
echo "Setup python venv..."
python -m venv venv
source venv/bin/activate
export CFLAGS=-fcommon
echo "Install pip requirements..."
pip install -r requirements.txt
deactivate
mkdir /home/pi/luniebox/config
echo "Setup config and systemd services..."
cp /home/pi/luniebox/contrib/config/luniebox.cfg /home/pi/luniebox/config/luniebox.cfg
sudo cp /home/pi/luniebox/contrib/service/luniebox-app.service /etc/systemd/system/
sudo cp /home/pi/luniebox/contrib/service/luniebox-daemon.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable luniebox-app luniebox-daemon
if [[ -z ${SETUP_APP+x} ]]; then
echo "Install required packages..."
sudo apt install -y python3-venv python3-pip
cd /home/pi/luniebox/application
echo "Setup python venv..."
python -m venv venv
source venv/bin/activate
export CFLAGS=-fcommon
echo "Install pip requirements..."
pip install -r requirements.txt
deactivate
echo "Setup config and systemd services..."
cp /home/pi/luniebox/contrib/config/luniebox.cfg /home/pi/luniebox/config/luniebox.cfg
sudo cp /home/pi/luniebox/contrib/service/luniebox-app.service /etc/systemd/system/
sudo cp /home/pi/luniebox/contrib/service/luniebox-daemon.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable luniebox-app luniebox-daemon
REBOOT=true
echo "SETUP_APP=true" | tee -a "${INSTALL_CONFIG_FILE}" 1>/dev/null
fi
}
setup_spotify() {
if [[ ${AUTOMATIC} == "false" ]]; then
read -rp "Do you want to install spotifyd for Spofity support? [Y/n] " response
echo ""
case "$response" in
[nN][oO] | [nN])
NO_SPOTIFY=true
return 0
;;
esac
if [[ -z ${SETUP_SPOTIFY+x} ]]; then
if [[ ${NO_SPOTIFY} == "false" ]]; then
if [[ ${AUTOMATIC} == "false" ]]; then
read -rp "Do you want to install spotifyd for Spofity support? [Y/n] " response
echo ""
case "$response" in
[nN][oO] | [nN])
NO_SPOTIFY=true
return 0
;;
esac
fi
mkdir -p /home/pi/luniebox/bin
echo "Download spotifyd..."
wget -c https://github.com/Spotifyd/spotifyd/releases/download/v0.3.3/spotifyd-linux-armv6-slim.tar.gz -O - | tar -xz -C /home/pi/luniebox/bin
echo "Setup config and systemd services..."
if [[ ${NO_AUDIO} == "true" ]]; then
echo "WARNING: you may need to adjust the file '/home/pi/luniebox/config/spotifyd.cfg' manually to setup your audio device!"
echo ""
fi
cp /home/pi/luniebox/contrib/config/spotifyd.cfg /home/pi/luniebox/config/spotifyd.cfg
sed -i "s/^device_name.*=.*$/device_name = \"${DEVICE_NAME}\"/" /home/pi/luniebox/config/spotifyd.cfg
sudo cp /home/pi/luniebox/contrib/service/spotifyd.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable spotifyd
REBOOT=true
echo "SETUP_SPOTIFY=true" | tee -a "${INSTALL_CONFIG_FILE}" 1>/dev/null
fi
fi
mkdir /home/pi/luniebox/bin
echo "Download spotifyd..."
wget -c https://github.com/Spotifyd/spotifyd/releases/download/v0.3.3/spotifyd-linux-armv6-slim.tar.gz -O - | tar -xz -C /home/pi/luniebox/bin
echo "Setup config and systemd services..."
if [[ ${NO_AUDIO} == "true" ]]; then
echo "WARNING: you may need to adjust the file '/home/pi/luniebox/config/spotifyd.cfg' manually to setup your audio device!"
echo ""
if [[ -z ${SETUP_NO_SPOTIFY+x} ]]; then
echo "SETUP_NO_SPOTIFY=${NO_SPOTIFY}" | tee -a "${INSTALL_CONFIG_FILE}" 1>/dev/null
else
NO_SPOTIFY="${SETUP_NO_SPOTIFY}"
fi
cp /home/pi/luniebox/contrib/config/spotifyd.cfg /home/pi/luniebox/config/spotifyd.cfg
sudo cp /home/pi/luniebox/contrib/service/spotifyd.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable spotifyd
}
setup_mpd() {
if [[ ${AUTOMATIC} == "false" ]]; then
read -rp "Do you want to install mpd (Music Player Daemon) for offline file support? [Y/n] " response
echo ""
case "$response" in
[nN][oO] | [nN])
NO_MPD=true
return 0
;;
esac
if [[ -z ${SETUP_MPD+x} ]]; then
if [[ ${NO_MPD} == "false" ]]; then
if [[ ${AUTOMATIC} == "false" ]]; then
read -rp "Do you want to install mpd (Music Player Daemon) for offline file support? [Y/n] " response
echo ""
case "$response" in
[nN][oO] | [nN])
NO_MPD=true
return 0
;;
esac
fi
mkdir -p /home/pi/luniebox/library
echo "Install required packages..."
sudo apt install -y mpd
echo "Setup config..."
if [[ ${NO_AUDIO} == "true" ]]; then
echo "WARNING: you may need to adjust the file '/etc/mpd.conf' manually to setup your audio device!"
echo ""
fi
sudo cp /home/pi/luniebox/contrib/config/mpd.conf /etc/mpd.conf
REBOOT=true
echo "SETUP_MPD=true" | tee -a "${INSTALL_CONFIG_FILE}" 1>/dev/null
fi
fi
mkdir /home/pi/luniebox/library
echo "Install required packages..."
sudo apt install -y mpd
echo "Setup config..."
if [[ ${NO_AUDIO} == "true" ]]; then
echo "WARNING: you may need to adjust the file '/etc/mpd.conf' manually to setup your audio device!"
echo ""
if [[ -z ${SETUP_NO_MPD+x} ]]; then
echo "SETUP_NO_MPD=${NO_MPD}" | tee -a "${INSTALL_CONFIG_FILE}" 1>/dev/null
else
NO_MPD="${SETUP_NO_MPD}"
fi
sudo cp /home/pi/luniebox/contrib/config/mpd.conf /etc/mpd.conf
}
setup_zspotify() {
if [[ ${NO_SPOTIFY} == "false" ]] && [[ ${NO_MPD} == "false" ]]; then
if [[ ${AUTOMATIC} == "false" ]]; then
read -rp "Do you want to install zspotify for downloading Spotify tracks for offline support? [Y/n] " response
if [[ -z ${SETUP_SPOTIFYDL+x} ]]; then
if [[ ${NO_SPOTIFYDL} == "false" ]] && [[ ${NO_SPOTIFY} == "false" ]] && [[ ${NO_MPD} == "false" ]]; then
if [[ ${AUTOMATIC} == "false" ]]; then
read -rp "Do you want to install zspotify for downloading Spotify tracks for offline support? [Y/n] " response
echo ""
case "$response" in
[nN][oO] | [nN])
NO_MPD=true
return 0
;;
esac
fi
echo "Fetch clspotify repository..."
git clone https://github.com/agent255/clspotify.git /home/pi/clspotify
cd /home/pi/clspotify
echo "Setup python venv..."
python -m venv venv
source venv/bin/activate
echo "Install pip requirements..."
pip install -r requirements.txt
deactivate
echo "Setup config..."
sed -i "s/^zspotify_path =.*$/zspotify_path = \/home\/pi\/clspotify\//" /home/pi/luniebox/config/luniebox.cfg
REBOOT=true
echo "SETUP_SPOTIFYDL=true" | tee -a "${INSTALL_CONFIG_FILE}" 1>/dev/null
fi
fi
if [[ -z ${SETUP_NO_SPOTIFY+x} ]]; then
echo "SETUP_NO_SPOTIFYDL=${NO_SPOTIFYDL}" | tee -a "${INSTALL_CONFIG_FILE}" 1>/dev/null
else
NO_SPOTIFYDL="${SETUP_NO_SPOTIFYDL}"
fi
}
setup_device_name() {
if [[ -z ${SETUP_DEVICE_NAME+x} ]]; then
if [[ ${AUTOMATIC} == "false" ]] && [[ ${DEVICE_NAME} == "false" ]]; then
read -rp "Name for your Luniebox devices [default: luniebox]: " DEVICE_NAME
fi
if ! [[ $DEVICE_NAME ]] || [[ ${DEVICE_NAME} == "false" ]]; then
DEVICE_NAME="luniebox"
fi
echo "Set device name to '${DEVICE_NAME}'"
printf "${DEVICE_NAME}" | sudo tee /etc/hostname 1>/dev/null
sudo sed -i "/^127.0.0.1/s/$/ ${DEVICE_NAME}/g" /etc/hosts
REBOOT=true
echo "SETUP_DEVICE_NAME=${DEVICE_NAME}" | tee -a "${INSTALL_CONFIG_FILE}" 1>/dev/null
else
DEVICE_NAME="${SETUP_DEVICE_NAME}"
fi
}
setup_rfid() {
if [[ -z ${SETUP_RFID+x} ]]; then
echo "Enable SPI for RFID reader"
sudo sed -i "/dtparam=spi=on/s/^#//g" /boot/config.txt
REBOOT=true
echo "SETUP_RFID=true" | tee -a "${INSTALL_CONFIG_FILE}" 1>/dev/null
fi
}
setup_mpu() {
if [[ -z ${SETUP_MPU+x} ]]; then
if [[ ${AUTOMATIC} == "false" ]] && [[ ${NO_MPU} == "true" ]]; then
read -rp "Do you want to setup I2C for MPU9250 9-axis sensor? [y/N] " response
echo ""
case "$response" in
[nN][oO] | [nN])
NO_MPD=true
[yY][eE][sS] | [yY])
NO_MPU=false
;;
*)
return 0
;;
esac
fi
echo "Fetch clspotify repository..."
git clone https://github.com/agent255/clspotify.git /home/pi/clspotify
cd /home/pi/clspotify
echo "Setup python venv..."
python -m venv venv
source venv/bin/activate
echo "Install pip requirements..."
pip install -r requirements.txt
deactivate
echo "Setup config..."
sed -i "s/^zspotify_path =.*$/zspotify_path = \/home\/pi\/clspotify\//" /home/pi/luniebox/config/luniebox.cfg
fi
}
set_device_name() {
if [[ ${AUTOMATIC} == "false" ]] && [[ ${DEVICE_NAME} == "false" ]]; then
read -rp "Name for your Luniebox devices [default: luniebox]: " DEVICE_NAME
if [[ ${NO_MPU} == "false" ]]; then
echo "Install I2C software, enable i2c bus 4, enable mpu"
sudo apt install -y i2c-tools python3-smbus
sudo sed -i "/dtparam=i2c_arm=on/s/^#//g" /boot/config.txt
printf "\n# setup i2c bus 4 for mpu\ndtoverlay=i2c-gpio,bus=4,i2c_gpio_delay_us=1,i2c_gpio_sda=23,i2c_gpio_scl=24\n" | sudo tee -a /boot/config.txt 1>/dev/null
sed -i "s/^mpu =.*$/mpu = True/" /home/pi/luniebox/config/luniebox.cfg
REBOOT=true
echo "SETUP_MPU=true" | tee -a "${INSTALL_CONFIG_FILE}" 1>/dev/null
fi
fi
if ! [[ $DEVICE_NAME ]] || [[ ${DEVICE_NAME} == "false" ]]; then
DEVICE_NAME="luniebox"
fi
echo "Set device name to '${DEVICE_NAME}'"
printf "${DEVICE_NAME}" | sudo tee /etc/hostname 1>/dev/null
sudo sed -i "/^127.0.0.1/s/$/ ${DEVICE_NAME}/g" /etc/hosts
if [[ NO_SPOTIFY == "false" ]]; then
sed -i "s/^device_name.*=.*$/device_name = \"${DEVICE_NAME}\"/" /home/pi/luniebox/config/spotifyd.cfg
fi
}
setup_rfid() {
echo "Enable SPI for RFID reader"
sudo sed -i "/dtparam=spi=on/s/^#//g" /boot/config.txt
}
setup_mpu() {
if [[ ${AUTOMATIC} == "false" ]] && [[ ${MPU} == "false" ]]; then
read -rp "Do you want to setup I2C for MPU9250 9-axis sensor? [y/N] " response
echo ""
case "$response" in
[yY][eE][sS] | [yY])
MPU=true
break
;;
*)
return 0
;;
esac
fi
if [[ ${MPU} == "true" ]]; then
echo "Install I2C software, enable i2c bus 4, enable mpu"
sudo apt install -y i2c-tools python3-smbus
sudo sed -i "/dtparam=i2c_arm=on/s/^#//g" /boot/config.txt
printf "dtoverlay=i2c-gpio,bus=4,i2c_gpio_delay_us=1,i2c_gpio_sda=23,i2c_gpio_scl=24" | sudo tee -a /boot/config.txt 1>/dev/null
sed -i "s/^mpu =.*$/mpu = True/" /home/pi/luniebox/config/luniebox.cfg
if [[ -z ${SETUP_NO_MPU+x} ]]; then
echo "SETUP_NO_MPU=${NO_MPU}" | tee -a "${INSTALL_CONFIG_FILE}" 1>/dev/null
else
NO_MPU="${SETUP_NO_MPU}"
fi
}
setup_audio() {
if [[ ${AUTOMATIC} == "false" ]]; then
echo "Choose your audio hardware"
select response in "${AUDIO_DEVICES[@]}"; do
echo ""
AUDIO_DEVICE="$response"
break
done
if [[ -z ${SETUP_AUDIO+x} ]]; then
if [[ ${NO_AUDIO} == "false" ]]; then
if [[ ${AUTOMATIC} == "false" ]]; then
echo "Choose your audio hardware"
select response in "${AUDIO_DEVICES[@]}"; do
echo ""
AUDIO_DEVICE="$response"
break
done
fi
case "$AUDIO_DEVICE" in
"pimoroni")
setup_pimoroni
;;
"adafruit")
setup_adafruit
;;
*)
NO_AUDIO=true
echo "WARNING: please setup your audio device manually!"
;;
esac
fi
fi
case "$AUDIO_DEVICE" in
"pimoroni")
setup_pimoroni
;;
"adafruit")
setup_adafruit
;;
*)
NO_AUDIO=true
echo "WARNING: please setup your audio device manually!"
;;
esac
if [[ -z ${SETUP_AUDIO_DEVICE+x} ]]; then
echo "SETUP_AUDIO_DEVICE=${AUDIO_DEVICE}" | tee -a "${INSTALL_CONFIG_FILE}" 1>/dev/null
else
AUDIO_DEVICE="${SETUP_AUDIO_DEVICE}"
fi
if [[ -z ${SETUP_NO_AUDIO+x} ]]; then
echo "SETUP_NO_AUDIO=${NO_AUDIO}" | tee -a "${INSTALL_CONFIG_FILE}" 1>/dev/null
else
NO_AUDIO="${SETUP_NO_AUDIO}"
fi
}
setup_pimoroni() {
echo "Setup Pimoroni Shim"
sudo sed -i "/dtparam=audio=on/s/^/#/g" /boot/config.txt
printf "dtoverlay=hifiberry-dac\ngpio=25=op,dh" | sudo tee -a /boot/config.txt 1>/dev/null
printf "\n# setup hifiberry for Pimoroni Shim\ndtoverlay=hifiberry-dac\ngpio=25=op,dh\n" | sudo tee -a /boot/config.txt 1>/dev/null
REBOOT=true
echo "SETUP_AUDIO=true" | tee -a "${INSTALL_CONFIG_FILE}" 1>/dev/null
}
setup_adafruit() {
echo "Setup Adafruit Speaker Bonnet"
sudo sed -i "/dtparam=audio=on/s/^/#/g" /boot/config.txt
printf "dtoverlay=hifiberry-dac\ndtoverlay=i2s-mmap" | sudo tee -a /boot/config.txt 1>/dev/null
printf "\n# setup hifiberry and i2s for Adafruit Speaker Bonnet\ndtoverlay=hifiberry-dac\ndtoverlay=i2s-mmap\n" | sudo tee -a /boot/config.txt 1>/dev/null
cat /home/pi/luniebox/contrib/config/asound.conf | sudo tee /etc/asound.conf 1>/dev/null
cat /home/pi/luniebox/contrib/config/.asoundrc | tee /home/pi/.asoundrc 1>/dev/null
REBOOT=true
echo "SETUP_AUDIO=true" | tee -a "${INSTALL_CONFIG_FILE}" 1>/dev/null
}
finalize() {
if [[ ${AUTOMATIC} == "false" ]]; then
read -rp "Setup finished and reboot required. Do you want to automatically reboot your luniebox now? [Y/n] " response
echo ""
case "$response" in
[nN][oO] | [nN])
echo "Please reboot manually for luniebox working properly!"
echo "Bye...."
exit 0
;;
esac
fi
if [[ ${REBOOT} == "true" ]]; then
if [[ ${AUTOMATIC} == "false" ]]; then
read -rp "Setup finished and reboot required. Do you want to automatically reboot your luniebox now? [Y/n] " response
echo ""
case "$response" in
[nN][oO] | [nN])
echo "Please reboot manually for luniebox working properly!"
echo "Bye...."
exit 0
;;
esac
fi
echo "Rebooting now...."
sleep 2
sudo reboot
exit
echo "Rebooting now...."
sleep 1
sudo reboot
exit 0
else
echo "Bye...."
exit 0
fi
}
start