7 Commits

Author SHA1 Message Date
Adrian Zürcher
3aac950b9c add new debian install workflow for linux
All checks were successful
Build Slideshow App / build (amd64, .exe, windows) (push) Successful in 1m49s
Build Slideshow App / build (amd64, , linux) (push) Successful in 2m8s
Build Slideshow App / build (arm, 7, , linux) (push) Successful in 1m53s
Build Slideshow App / build (arm64, , linux) (push) Successful in 1m51s
2026-01-17 22:42:16 +01:00
Adrian Zürcher
96bfcb7d0e add new set function 2026-01-17 22:41:54 +01:00
Adrian Zürcher
64744e218a add feature check if ip is active 2026-01-17 22:41:42 +01:00
Adrian Zürcher
7d3db6b485 remove schedule.json file 2026-01-17 22:41:21 +01:00
Adrian Zürcher
9cde384a36 add browser open function 2026-01-17 22:39:50 +01:00
f9a92e4e4a Fix appname artifact
All checks were successful
Build Slideshow App / build (amd64, .exe, windows) (push) Successful in 1m56s
Build Slideshow App / build (amd64, , linux) (push) Successful in 2m2s
Build Slideshow App / build (arm, 6, , linux) (push) Successful in 1m42s
Build Slideshow App / build (arm64, , linux) (push) Successful in 1m48s
2026-01-17 18:12:49 +01:00
40b13a0661 Change upload v4 to v3
All checks were successful
Build Slideshow App / build (amd64, .exe, windows) (push) Successful in 2m2s
Build Slideshow App / build (amd64, , linux) (push) Successful in 2m16s
Build Slideshow App / build (arm, 6, , linux) (push) Successful in 1m50s
Build Slideshow App / build (arm64, , linux) (push) Successful in 1m45s
2026-01-17 15:10:58 +01:00
7 changed files with 258 additions and 112 deletions

View File

@@ -1,93 +1,141 @@
name: Build Slideshow App
on:
push:
tags:
- '*'
env:
APP_NAME: slideshowApp
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- os: windows
arch: amd64
ext: .exe
- os: linux
arch: amd64
ext: ""
- os: linux
arch: arm64
ext: ""
- os: linux
arch: arm
arm_version: 6
ext: ""
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Ensure latest Go is installed in /data/go
run: |
export GOROOT=/data/go/go
export PATH=$GOROOT/bin:$PATH
export GOCACHE=/data/gocache
export GOMODCACHE=/data/gomodcache
mkdir -p $GOCACHE $GOMODCACHE
if [ ! -x "$GOROOT/bin/go" ]; then
echo "Go not found in $GOROOT, downloading latest stable..."
GO_VERSION=$(curl -s https://go.dev/VERSION?m=text | head -n1)
echo "Latest version is $GO_VERSION"
mkdir -p /data/go
curl -sSL "https://go.dev/dl/${GO_VERSION}.linux-amd64.tar.gz" -o /tmp/go.tar.gz
tar -C /data/go -xzf /tmp/go.tar.gz
else
echo "Using cached Go from $GOROOT"
fi
go version
- name: Download Go dependencies
run: |
export GOROOT=/data/go/go
export PATH=$GOROOT/bin:$PATH
export GOCACHE=/data/gocache
export GOMODCACHE=/data/gomodcache
mkdir -p $GOCACHE $GOMODCACHE
go mod download
- name: Build binary
run: |
export GOROOT=/data/go/go
export PATH=$GOROOT/bin:$PATH
export GOCACHE=/data/gocache
export GOMODCACHE=/data/gomodcache
mkdir -p $GOCACHE $GOMODCACHE
OUTPUT="${APP_NAME}"
if [ -n "${{ matrix.arm_version }}" ]; then
OUTPUT="${OUTPUT}v${{ matrix.arm_version }}"
export GOARM=${{ matrix.arm_version }}
fi
OUTPUT="${OUTPUT}${{ matrix.ext }}"
echo "Building $OUTPUT"
GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -ldflags="-s -w" -trimpath -o "$OUTPUT"
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.APP_NAME }}-${{ matrix.os }}-${{ matrix.arch }}
path: |
./web
${APP_NAME}${{ matrix.ext }}
name: Build Slideshow App
on:
push:
tags:
- '*'
env:
APP_NAME: slideshowApp
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- os: windows
arch: amd64
ext: .exe
- os: linux
arch: amd64
ext: ""
- os: linux
arch: arm64
ext: ""
- os: linux
arch: arm
arm_version: 7
ext: ""
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Ensure latest Go is installed in /data/go
run: |
export GOROOT=/data/go/go
export PATH=$GOROOT/bin:$PATH
export GOCACHE=/data/gocache
export GOMODCACHE=/data/gomodcache
mkdir -p $GOCACHE $GOMODCACHE
if [ ! -x "$GOROOT/bin/go" ]; then
echo "Go not found in $GOROOT, downloading latest stable..."
GO_VERSION=$(curl -s https://go.dev/VERSION?m=text | head -n1)
echo "Latest version is $GO_VERSION"
mkdir -p /data/go
curl -sSL "https://go.dev/dl/${GO_VERSION}.linux-amd64.tar.gz" -o /tmp/go.tar.gz
tar -C /data/go -xzf /tmp/go.tar.gz
else
echo "Using cached Go from $GOROOT"
fi
go version
- name: Download Go dependencies
run: |
export GOROOT=/data/go/go
export PATH=$GOROOT/bin:$PATH
export GOCACHE=/data/gocache
export GOMODCACHE=/data/gomodcache
mkdir -p $GOCACHE $GOMODCACHE
go mod download
- name: Build binary
run: |
export GOROOT=/data/go/go
export PATH=$GOROOT/bin:$PATH
export GOCACHE=/data/gocache
export GOMODCACHE=/data/gomodcache
mkdir -p $GOCACHE $GOMODCACHE
OUTPUT="${APP_NAME}"
if [ -n "${{ matrix.arm_version }}" ]; then
export GOARM=${{ matrix.arm_version }}
fi
OUTPUT="${OUTPUT}"
echo "Building $OUTPUT"
GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -ldflags="-s -w" -trimpath -o "$OUTPUT"
shell: bash
- name: Create Debian Package
if: matrix.os == 'linux'
run: |
# 1. Setup Variables
VERSION=${GITHUB_REF_NAME#v} # Extracts 1.0.0 from v1.0.0
ARCH=${{ matrix.arch }}
if [ "$ARCH" == "arm" ]; then ARCH="armhf"; fi
PKG_NAME="slideshowapp"
BUILD_DIR="${PKG_NAME}_${VERSION}_${ARCH}"
# 2. Create Directory Structure
mkdir -p $BUILD_DIR/usr/bin
mkdir -p $BUILD_DIR/usr/share/$PKG_NAME
mkdir -p $BUILD_DIR/DEBIAN
# 3. Copy Files
cp ${APP_NAME} $BUILD_DIR/usr/bin/$PKG_NAME
cp -r ./web $BUILD_DIR/usr/share/$PKG_NAME/
chmod +x $BUILD_DIR/usr/bin/$PKG_NAME
# 4. Create Control File
cat <<EOF > $BUILD_DIR/DEBIAN/control
Package: $PKG_NAME
Version: $VERSION
Section: utils
Priority: optional
Architecture: $ARCH
Maintainer: Your Name <you@example.com>
Description: Slideshow Application
EOF
# 5. Build .deb
dpkg-deb --build $BUILD_DIR
shell: bash
# Upload for Windows (Binary + Web folder)
- name: Upload Windows Artifact
if: matrix.os == 'windows'
uses: actions/upload-artifact@v3
with:
name: ${{ env.APP_NAME }}-windows
path: |
${{ env.APP_NAME }}.exe
./web
# Upload for Linux (Binary + .deb)
- name: Upload Linux Artifact
if: matrix.os == 'linux'
uses: actions/upload-artifact@v3
with:
name: ${{ env.APP_NAME }}-linux-${{ matrix.arch }}
path: |
${{ env.APP_NAME }}
*.deb

3
.gitignore vendored
View File

@@ -1,2 +1,3 @@
images/
slideshowApp
slideshowApp
schedule.json

4
env/enviroment.go vendored
View File

@@ -28,6 +28,10 @@ func (key EnvKey) GetValue() string {
return os.Getenv(string(key))
}
func (key EnvKey) SetValue(value string) {
os.Setenv(string(key), value)
}
func (key EnvKey) GetBoolValue() bool {
value := strings.ToLower(os.Getenv(string(key)))
return value == "true" || value == "1"

View File

@@ -5,32 +5,34 @@ import (
"net"
"net/http"
"slideshowApp/env"
"strings"
)
// Helper to get the local network IP address
func getLocalIP() string {
func GetLocalIP() string {
if env.Host.GetValue() != "0.0.0.0" && env.Host.GetValue() != "localhost" {
return env.Host.GetValue()
}
addrs, err := net.InterfaceAddrs()
if err != nil {
return "localhost"
}
for _, address := range addrs {
if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
if ipnet.IP.To4() != nil {
if env.Env.GetValue() == "development" && !strings.Contains(ipnet.IP.String(), "192.168") {
continue
}
return ipnet.IP.String()
}
}
if ip := getActiveIP(); ip != "" {
return ip
}
return "localhost"
}
func getActiveIP() string {
conn, err := net.Dial("udp", "8.8.8.8:80")
if err != nil {
return ""
}
defer conn.Close()
addr := conn.LocalAddr()
if udpAddr, ok := addr.(*net.UDPAddr); ok {
return udpAddr.IP.String()
}
return ""
}
func InfoHandler(w http.ResponseWriter, r *http.Request) {
port := env.Port.GetValue()
if port == "" {
@@ -43,7 +45,7 @@ func InfoHandler(w http.ResponseWriter, r *http.Request) {
}
data := map[string]string{
"ip": getLocalIP(),
"ip": GetLocalIP(),
"port": port,
"speed": speed,
}

13
main.go
View File

@@ -7,6 +7,8 @@ import (
"os"
"slideshowApp/env"
"slideshowApp/handlers"
"slideshowApp/utils"
"time"
"github.com/gorilla/mux"
)
@@ -23,11 +25,14 @@ func main() {
if _, err := os.Stat(uploadFolder); err != nil {
fmt.Println("upload folder for images not found: ", uploadFolder)
fmt.Println("use fallback")
fmt.Println("use fallback folder")
uploadFolder = "./images"
env.PhotoDir.SetValue(uploadFolder)
}
fmt.Println("upload folder for images: ", uploadFolder)
r.PathPrefix("/uploads/").Handler(http.StripPrefix("/uploads/", http.FileServer(http.Dir(uploadFolder))))
r.HandleFunc("/api/images", handlers.ListFilesHandler).Methods("GET")
r.HandleFunc("/ws", handlers.Websocket)
@@ -54,6 +59,12 @@ func main() {
host := env.Host.GetValue()
port := env.Port.GetValue()
url := fmt.Sprintf("%s:%s", host, port)
go func() {
time.Sleep(3 * time.Second)
if err := utils.OpenBrowser(fmt.Sprintf("%s:%s/slideshow", handlers.GetLocalIP(), port)); err != nil {
fmt.Println(err)
}
}()
fmt.Println("Server running at", url)
log.Fatal(http.ListenAndServe(url, r))
}

View File

@@ -1 +0,0 @@
{"Friday_active":false,"Friday_end":"07:38","Friday_start":"07:00","Monday_active":false,"Monday_end":"22:00","Monday_start":"08:00","Saturday_active":false,"Saturday_end":"22:00","Saturday_start":"08:00","Sunday_active":false,"Sunday_end":"22:00","Sunday_start":"08:00","Thursday_active":false,"Thursday_end":"22:00","Thursday_start":"08:00","Tuesday_active":false,"Tuesday_end":"22:00","Tuesday_start":"08:00","Wednesday_active":false,"Wednesday_end":"22:00","Wednesday_start":"08:00"}

81
utils/utils.go Normal file
View File

@@ -0,0 +1,81 @@
package utils
import (
"fmt"
"os"
"os/exec"
"runtime"
)
func OpenBrowser(url string) error {
var commands [][]string
switch runtime.GOOS {
case "windows":
commands = [][]string{
// Chrome (most common)
{`C:\Program Files\Google\Chrome\Application\chrome.exe`, "--kiosk", url},
{`C:\Program Files (x86)\Google\Chrome\Application\chrome.exe`, "--kiosk", url},
// Edge (default on modern Windows)
{`C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe`, "--kiosk", url},
{`C:\Program Files\Microsoft\Edge\Application\msedge.exe`, "--kiosk", url},
// Firefox (no true kiosk, but fullscreen)
{`C:\Program Files\Mozilla Firefox\firefox.exe`, "--kiosk", url},
{`C:\Program Files (x86)\Mozilla Firefox\firefox.exe`, "--kiosk", url},
// System default browser (always works)
{"rundll32", "url.dll,FileProtocolHandler", url},
}
case "darwin":
commands = [][]string{
// Chrome
{"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", "--kiosk", url},
// Edge
{"/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge", "--kiosk", url},
// Firefox
{"/Applications/Firefox.app/Contents/MacOS/firefox", "--kiosk", url},
// Safari (no kiosk flag, opens normally)
{"open", "-a", "Safari", url},
// System default browser
{"open", url},
}
default: // Linux
if os.Getenv("DISPLAY") == "" &&
os.Getenv("WAYLAND_DISPLAY") == "" &&
os.Getenv("XDG_SESSION_TYPE") != "wayland" {
return fmt.Errorf("os is running in headless mode; do not start browser")
}
commands = [][]string{
// Chromium / Chrome
{"chromium-browser", "--kiosk", url},
{"chromium", "--kiosk", url},
{"google-chrome", "--kiosk", url},
// Firefox
{"firefox", "--kiosk", url},
// System default browser (best universal fallback)
{"xdg-open", url},
}
}
for _, cmd := range commands {
execCmd := exec.Command(cmd[0], cmd[1:]...)
if err := execCmd.Start(); err == nil {
return nil
} else {
return err
}
}
return fmt.Errorf("could not open browser")
}