diff --git a/README.md b/README.md index 6efc686..d75a0ca 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ That's when I realized... maybe there are other people (or future me) who'd also Either open terminal on the Raspberry Pi's desktop environment, or remote login to it; and run the following command: ```bash -curl -sSL https://raw.githubusercontent.com/debloper/piosk/main/scripts/setup.sh | sudo bash - +curl -sSL https://raw.githubusercontent.com/thomaspcole/piosk/main/scripts/setup.sh | sudo bash - ``` That's it[^2]. diff --git a/config.json.sample b/config.json.sample index f590e60..e704fa9 100644 --- a/config.json.sample +++ b/config.json.sample @@ -1,25 +1,10 @@ { "urls": [ { - "url": "https://windy.com/" - }, - { - "url": "https://time.is/clock" - }, - { - "url": "https://github.com/trending" - }, - { - "url": "https://news.ycombinator.com/" - }, - { - "url": "https://huggingface.co/papers" - }, - { - "url": "https://www.perplexity.ai/discover" - }, - { - "url": "https://www.google.com/search?q=nasdaq+index" + "url": "http://localhost/setup" } - ] + ], + "settings":{ + "page_timeout": 10 + } } diff --git a/index.js b/index.js index 9d46198..30b1256 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,7 @@ const exp = require('express') const exe = require('child_process').exec const nfs = require('fs') +const os = require('os') const app = exp() @@ -27,4 +28,15 @@ app.post('/config', (req, res) => { }) }) +app.get('/setup', (req, res) => { + res.sendFile(__dirname + '/web/setup.html') +}) + +app.get('/sysinfo', (req, res) => { + res.json({ + hostname: os.hostname(), + ip: os.networkInterfaces(), + }) +}) + app.listen(80, console.error) diff --git a/scripts/setup.sh b/scripts/setup.sh index bfd44a4..c8333d0 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -38,7 +38,7 @@ echo -e "${INFO}Installing dependencies...${RESET}" apt install -y git jq wtype nodejs npm echo -e "${INFO}Cloning repository...${RESET}" -git clone https://github.com/debloper/piosk.git "$PIOSK_DIR" +git clone https://github.com/thomaspcole/piosk.git "$PIOSK_DIR" cd "$PIOSK_DIR" # echo -e "${INFO}Checking out latest release...${RESET}" @@ -88,6 +88,9 @@ echo -e "${INFO}Starting PiOSK daemons...${RESET}" # systemctl start piosk-switcher systemctl start piosk-dashboard +echo -e "${INFO}Disabling Mouse Cursor...${RESET}" +mv /usr/share/icons/PiXflat/cursors/left_ptr /usr/share/icons/PiXflat/cursors/left_prt.bak + echo -e "${CALLOUT}\nPiOSK is now installed.${RESET}" echo -e "Visit either of these links to access PiOSK dashboard:" echo -e "\t- ${INFO}\033[0;32mhttp://$(hostname)/${RESET} or," diff --git a/scripts/switcher.sh b/scripts/switcher.sh index ba68e7b..79467c1 100755 --- a/scripts/switcher.sh +++ b/scripts/switcher.sh @@ -8,6 +8,7 @@ export XDG_RUNTIME_DIR=/run/user/1000 # count the number of URLs, that are configured to cycle through URLS=$(jq -r '.urls | length' /opt/piosk/config.json) +TIMEOUT=$(jq '.settings.page_timeout' /opt/piosk/config.json) # swich tabs each 10s, refresh tabs each 10th cycle & then reset for ((TURN=1; TURN<=$((10*URLS)); TURN++)) do @@ -20,5 +21,5 @@ for ((TURN=1; TURN<=$((10*URLS)); TURN++)) do fi fi fi - sleep 10 + sleep $TIMEOUT done diff --git a/scripts/update.sh b/scripts/update.sh new file mode 100644 index 0000000..6d3b445 --- /dev/null +++ b/scripts/update.sh @@ -0,0 +1,28 @@ +#!/bin/bash +set -e + +# Installation directory +PIOSK_DIR="/opt/piosk" + +RESET='\033[0m' # Reset to default +ERROR='\033[1;31m' # Bold Red +SUCCESS='\033[1;32m' # Bold Green +WARNING='\033[1;33m' # Bold Yellow +INFO='\033[1;34m' # Bold Blue +CALLOUT='\033[1;35m' # Bold Magenta +DEBUG='\033[1;36m' # Bold Cyan + +echo -e "${INFO}Checking superuser privileges...${RESET}" +if [ "$EUID" -ne 0 ]; then + echo -e "${DEBUG}Escalating privileges as superuser...${RESET}" + + sudo "$0" "$@" # Re-execute the script as superuser + exit $? # Exit with the status of the sudo command +fi + +echo -e "${INFO}Updating Repo...${RESET}" +cd $PIOSK_DIR +git pull + +echo -e "${SUCCESS}\tUpdate done! Restarting...${RESET}" +reboot \ No newline at end of file diff --git a/web/index.html b/web/index.html index 89eb409..ab6822c 100644 --- a/web/index.html +++ b/web/index.html @@ -9,8 +9,8 @@