diff --git a/app.py b/app.py
index 872173e..3ea7734 100755
--- a/app.py
+++ b/app.py
@@ -25,7 +25,7 @@ hosts_available, hosts_unavailable = [],[]
# Map vlc cmds
# See https://github.com/videolan/vlc/blob/1336447566c0190c42a1926464fa1ad2e59adc4f/share/lua/http/requests/README.txt
-cmd = {
+cmd_player = {
"play" : "pl_play",
"resume" : "pl_forceresume",
"pause" : "pl_forcepause",
@@ -53,13 +53,15 @@ cmd = {
#"key" : "key=",
#"browse" : "browse.xml?uri=file://~"
# System commands :
- "rssi" : "rssi",
- "blink" : "blink",
- "poweroff" : "poweroff",
- "reboot" : "reboot",
+ # ~ "rssi" : "rssi",
+ # ~ "blink" : "blink",
+ # ~ "poweroff" : "poweroff",
+ # ~ "reboot" : "reboot",
}
+cmd_server = ["blink", "reboot", "poweroff", "rssi"]
+
# Set configuration
DEBUG = app.config['DEFAULT']['DEBUG']
@@ -137,9 +139,11 @@ def httpUpload(filename, hostl, trailing_slash=1):
if not trailing_slash:
filename = "/" + filename
files = { "file":( filename, open( media_folder_local + filename, "rb"), "multipart/form-data") }
- print(files)
+ if DEBUG:
+ print(files)
resp = requests.post(url, files=files, headers=headers, verify=CAfile)
- print(resp.text)
+ if DEBUG:
+ print(resp.text)
if resp.ok:
return 1
else:
@@ -209,17 +213,11 @@ def sendCommand(host, arg0, arg1, arg2):
req = "/requests/status.xml"
if arg0 == "list" :
req = "/requests/playlist.xml"
- elif arg0 == "rssi":
- req = "/rssi"
+ elif arg0 in cmd_server:
+ req = "/" + str(arg0)
portl = cmd_port
- elif arg0 == "reboot":
- req = "/reboot"
- portl = cmd_port
- elif arg0 == "poweroff":
- req = "/poweroff"
- portl = cmd_port
elif arg0 != "status" :
- req = req + "?command=" + cmd[arg0]
+ req = req + "?command=" + cmd_player[arg0]
if arg1 != "null" :
if (arg0 == "play") or (arg0 == "delete") or (arg0 == "sort") or (arg0 == "move"):
req = req + "&id=" + arg1
@@ -245,6 +243,7 @@ def sendCommand(host, arg0, arg1, arg2):
try:
conn.request( "GET", req, headers = headers )
resp = conn.getresponse()
+ data = resp.read()
except http.client.HTTPException:
print("Connection to " + host + " timed out")
return "Connection to " + host + " timed out"
@@ -253,7 +252,7 @@ def sendCommand(host, arg0, arg1, arg2):
finally:
conn.close()
# Parse response
- data = resp.read()
+ # ~ data = resp.read()
if arg0 == "rssi":
if DEBUG:
@@ -366,7 +365,7 @@ def sync(host):
@app.route("////")
def action(host, arg0, arg1, arg2):
status_message = "Idle"
- if arg0 not in cmd:
+ if (arg0 not in cmd_player) and (arg0 not in cmd_server):
status_message = "Wrong command
"
elif host == "all":
resp = []
@@ -383,5 +382,4 @@ def action(host, arg0, arg1, arg2):
if __name__ == '__main__':
# ~ app.run()
- #serve(app, host='127.0.0.1', port=8080)
- serve(app, host='0.0.0.0', port=8080)
\ No newline at end of file
+ serve(app, host='127.0.0.1', port=8080)
\ No newline at end of file
diff --git a/changelog_todo.md b/changelog_todo.md
index c61e284..3f31a9c 100644
--- a/changelog_todo.md
+++ b/changelog_todo.md
@@ -29,8 +29,8 @@ sha256 : 0fe3fe76d0e56e445124fa20646fa8b3d8c59568786b3ebc8a96d83d92f203e3
* Webgui beautifying
## 0.4 : 2022-10-21-videopi.img.xz
-md5 : 2a54eb1763060db652c4c5d89c07ef2a
-sha256 : 10b65d5260222e4cdc591ad5384247cbc22d515dc55ea6b31b2daf0b6fd01004
+md5 : dee7af70135994169cab4f073ee51905
+sha256 : ec3e17fc9b41f8c5181484e9866be2d1d92cab8403210e3d22f4f689edd4cfde
* Switch to rpi os Bullseye
* Switch to user 'pil', pw 'pilpoil'
@@ -53,6 +53,7 @@ sha256 : 10b65d5260222e4cdc591ad5384247cbc22d515dc55ea6b31b2daf0b6fd01004
# DOING NEXT :
* ~ Test with several rpis
* Define http auth secret at setup
+ * Increase live host scan when host first found
# DONE :
diff --git a/linux_server_deploy.sh b/linux_server_deploy.sh
index 3a9a3fd..e415208 100755
--- a/linux_server_deploy.sh
+++ b/linux_server_deploy.sh
@@ -151,7 +151,7 @@ do
# Change hostname
echo "$HOST_NAME" | sudo tee "$ROOTFS_MOUNT/etc/hostname"
# Reflect that in /etc/hosts
- sed -i "$ d" "$ROOTFS_MOUNT/etc/hosts"
+ sudo sed -i "$ d" "$ROOTFS_MOUNT/etc/hosts"
echo -e "127.0.1.1\t$HOST_NAME" | sudo tee -a "$ROOTFS_MOUNT/etc/hosts"
## Enable SSH
green "Operation 5/13 : Enabling SSH server on boot ...\n"
@@ -165,7 +165,7 @@ do
if [ "$ADD_SSH_CONF" == "y" ]
then
# Add to ~/.ssh/config
- echo -e "Host $HOST_NAME\n\tHostName $HOST\n\tIdentityFile ~/.ssh/$HOST_NAME\n\tUser $PI_USER" | tee -a "$HOME/.ssh/config"
+ echo -e "\nHost $HOST_NAME\n\tHostname $HOST\n\tIdentityFile ~/.ssh/$HOST_NAME\n\tUser $PI_USER" | tee -a "$HOME/.ssh/config"
fi
# Copy public key to rpi
green "Operation 7/13 : Installing public SSH key $HOME/.ssh/$HOST.pub in $ROOTFS_MOUNT/home/$PI_USER/.ssh/authorized_keys...\n"
@@ -229,7 +229,7 @@ network={
umount $BOOT_MOUNT
umount $ROOTFS_MOUNT
yellow "Client $(($IP-9))/$CLIENT_NUMBER done."
- if [ $(($IP+1)) -lt $(($CLIENT_NUMBER+$IP)) ]
+ if [ $IP -le $IP_CNT ]
then
red "Please swap sd card in reader and enter uppercase 'yes' to proceed with next client :"
read -n 4 GO_ON
diff --git a/pilpil-server.toml b/pilpil-server.toml
index bb7b9cf..27f233a 100644
--- a/pilpil-server.toml
+++ b/pilpil-server.toml
@@ -10,7 +10,7 @@ media_exts = ["mp4", "avi", "mkv"]
auth = "secret"
# OnNlY3JldA==
cmd_auth = "secret"
-hosts = ["10.42.0.135", "10.42.0.11"]
+hosts = ["10.42.0.10", "10.42.0.11"]
# VLC http LUA port
port = 8887
# Clients cmd port
diff --git a/prepa_rpios.md b/prepa_rpios.md
index 5103f06..098d53d 100644
--- a/prepa_rpios.md
+++ b/prepa_rpios.md
@@ -156,6 +156,16 @@ Host 10.42.0.135
```
+## Sudoers : commandes systèmes sans mot de passe
+
+`/etc/sudoers.d/010_pilpil_nopasswd.conf` :
+
+```
+Cmnd_Alias PILPIL=/usr/sbin/reboot, /usr/sbin/poweroff, /usr/bin/tee
+pil ALL=(ALL) NOPASSWD: PILPIL
+```
+
+
## Systemd Unit : démarrage automatique des services
## VLC
diff --git a/static/script.js b/static/script.js
index 49af62a..d7b08f4 100644
--- a/static/script.js
+++ b/static/script.js
@@ -202,7 +202,7 @@ function parseResult(command, infos_array) {
document.getElementById("playlist_"+infos_array[i].host).innerHTML = infos_array[i].leng + " item(s) in playlist - " + infos_array[i].duration;
// Build html table and timeline
var items_array = Array.from(infos_array[i].items);
- console.log(items_array.length);
+ //console.log(items_array.length);
if (items_array.length == 0){
var child_list = Array.from(document.getElementById("timeline").children);
for(i=0,l=child_list.length;iβtst.mp4
-
+
@@ -43,6 +43,7 @@
+
{{status_message}}
Link: