diff --git a/install/install.sh b/install/install.sh new file mode 100644 index 0000000..a590ea0 --- /dev/null +++ b/install/install.sh @@ -0,0 +1,84 @@ +#!/bin/sh + +######### +# start # +######### + +# env setup +ovd_version="0.1.0" +export DEBIAN_FRONTEND="noninteractive" +set -e + +# banner +echo "Installer for OVDashboard ${ovd_version}" +echo "Waiting 10 seconds, press Ctrl+C to cancel installation ..." +sleep 10 + +################# +# prerequisites # +################# + +# 134: docker with compose +# 113: chromium browser +/boot/dietpi/dietpi-software install 134 113 + +# htpdate (timesync in restricted networks) +# unclutter (hides mouse cursor) +apt-get update && apt-get install --yes --no-install-recommends \ + htpdate unclutter + +# activate unclutter +echo '/usr/bin/unclutter -idle 0.1 &' > /etc/chromium.d/dietpi-unclutter + +# chromium window size +echo "Please enter your screen resolution!" + +screen_x="$( cut -d ',' -f 1 '/sys/class/graphics/fb0/virtual_size' )" +printf "Width [default: %d]: " "${screen_x}" +read -r screen_x_in +screen_x="${screen_x_in:-$screen_x}" +sed -ri "s/^(SOFTWARE_CHROMIUM_RES_X=)[0-9]+$/\1${screen_x}/" '/boot/dietpi.txt' + +screen_y="$( cut -d ',' -f 2 '/sys/class/graphics/fb0/virtual_size' )" +printf "Height [default: %d]: " "${screen_y}" +read -r screen_y_in +screen_y="${screen_y_in:-$screen_y}" +sed -ri "s/^(SOFTWARE_CHROMIUM_RES_Y=)[0-9]+$/\1${screen_y}/" '/boot/dietpi.txt' + +# chromium autostart +echo '11' > '/boot/dietpi/.dietpi-autostart_index' # magic number +sed -ri "s/^(AUTO_SETUP_AUTOSTART_LOGIN_USER=).+$/\1dietpi/" '/boot/dietpi.txt' # run as "dietpi" +sed -ri "s/^(SOFTWARE_CHROMIUM_AUTOSTART_URL=).+$/\1http:\/\/localhost\//" '/boot/dietpi.txt' # open "localhost" + +# chromium language +display_lang="en-US,en" +printf "Enter display language(s) [default: %s]: " "${display_lang}" +read -r display_lang_in +display_lang="${display_lang_in:-${display_lang}}" + +sudo -u dietpi mkdir -p '/home/dietpi/.config/chromium/Default' +echo '{"intl":{"selected_languages":"'"${display_lang}"'"}}' \ + | sudo -u dietpi tee '/home/dietpi/.config/chromium/Default/Preferences' \ + > /dev/null + +####### +# app # +####### + +mkdir -p /opt/ovdashboard + +# compose file +curl \ + --proto "=https" --tlsv1.2 -sSf \ + --output "/opt/ovdashboard/docker-compose.yml" \ + "https://code.yavook.de/OEKZident.de/ovdashboard/raw/tag/v${ovd_version}/install/docker-compose.yml" +echo "Please review the Docker Compose file before continuing! [press Enter]" +read -r _ENTER +nano "/opt/ovdashboard/docker-compose.yml" + +# start server +docker compose \ + --file "/opt/ovdashboard/docker-compose.yml" \ + --project-directory "/opt/ovdashboard" \ + --project-name "ovdashboard" \ + up --detach