Compare commits

...

6 Commits

Author SHA1 Message Date
Maxi Quoß 65d6e9fa86 update deps 2026-04-01 19:24:57 +02:00
monstercjz 6d53e9e197 fix(cron/wake): fix closure bugs, add reload hooks, and improve command robustness (#1723)
Co-authored-by: Maxi Quoß <maxi@quoss.org>
2026-04-01 19:21:47 +02:00
invario 6caddf25d0 Update README.md - reorganized parts and linked to Wiki instead (#1719)
Signed-off-by: invario <67800603+invario@users.noreply.github.com>
2026-04-01 18:59:33 +02:00
invario f7dc0b2113 Update docker-compose.yml (#1721)
Add note about nmap
Remove alternate entrypoint for adding packages (breaks functionality)
2026-04-01 18:57:39 +02:00
dependabot[bot] 314d338d08 build(deps): bump golang.org/x/image from 0.37.0 to 0.38.0 in /backend
Bumps [golang.org/x/image](https://github.com/golang/image) from 0.37.0 to 0.38.0.
- [Commits](https://github.com/golang/image/compare/v0.37.0...v0.38.0)

---
updated-dependencies:
- dependency-name: golang.org/x/image
  dependency-version: 0.38.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-30 16:30:08 +00:00
dependabot[bot] d8bdab2d2e build(deps): bump yaml from 1.10.2 to 1.10.3 in /frontend
Bumps [yaml](https://github.com/eemeli/yaml) from 1.10.2 to 1.10.3.
- [Release notes](https://github.com/eemeli/yaml/releases)
- [Commits](https://github.com/eemeli/yaml/compare/v1.10.2...v1.10.3)

---
updated-dependencies:
- dependency-name: yaml
  dependency-version: 1.10.3
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-25 20:55:35 +00:00
12 changed files with 780 additions and 1587 deletions
+15 -39
View File
@@ -34,6 +34,7 @@
- ⏰ Timed Events via Cron for Automation
- 🔌 Ping Any Port You Choose
- 🔍 Discover Devices with Network Scanning (nmap required)
- ❎️ Shutdown Devices with a Custom Command
- 👤 Secured User Management
- 🌐 i18n support for [these](/frontend/translations) languages
- 🎨 35 Themes
@@ -55,40 +56,19 @@
Just download the latest binary from the [release page](https://github.com/seriousm4x/UpSnap/releases) and run it.
### Root:
```sudo ./upsnap serve --http=0.0.0.0:8090```
```bash
sudo ./upsnap serve --http=0.0.0.0:8090
```
### Non-root on linux only:
```bash
sudo setcap cap_net_raw=+p ./upsnap # only once after downloading to allow for pinging devices
./upsnap serve --http=0.0.0.0:8090
```
To run as non-root (Linux only), refer to the Wiki: [Use non-root user](https://github.com/seriousm4x/UpSnap/wiki/Use-non%E2%80%90root-user)
For more options check `./upsnap --help` or visit [PocketBase documentation](https://pocketbase.io/docs).
If you want to use network discovery, make sure to have `nmap` installed and run UpSnap as root/admin.
## 🐳 Run in Docker
## 🐳 Run in docker
Just pull and run the image: `docker run --network=host seriousm4x/upsnap:latest` or you can use the [docker-compose](docker-compose.yml) example. See the comments in the file for customization.
You can use the [docker-compose](docker-compose.yml) example. See the comments in the file for customization.
To run as non-root, refer to the Wiki: [Use non-root user](https://github.com/seriousm4x/UpSnap/wiki/Use-non%E2%80%90root-user)
### Non-root docker user:
You will lose the ability to add network devices via the scan page.
Create the mount point first:
```bash
mkdir data
```
Then add `user: 1000:1000` to the docker-compose file (or whatever your $UID:$GID is).
### Change port
### Change port (Docker)
If you want to change the port from 8090 to something else, change the following (5000 in this case):
@@ -96,16 +76,10 @@ If you want to change the port from 8090 to something else, change the following
environment:
- UPSNAP_HTTP_LISTEN=0.0.0.0:5000
```
## ❎️ Shutting Down Devices
### Install additional packages for shutdown cmd
```yml
entrypoint: /bin/sh -c "apk update && apk add --no-cache <YOUR_PACKAGE> && rm -rf /var/cache/apk/* && ./upsnap serve"
```
You can search for your needed package [here](https://pkgs.alpinelinux.org/packages).
### Reverse Proxy
To shutdown devices, refer to the Wiki: [How to use shutdowns](https://github.com/seriousm4x/UpSnap/wiki/How-to-use-shutdowns)
## Reverse Proxy
**Caddy example**
@@ -115,7 +89,7 @@ upsnap.example.com {
}
```
### Run in sub path
## Run in sub path
You can run UpSnap on a different path than `/`, e.g. `/upsnap-sub-path/`. To do this in caddy, set the following:
@@ -163,14 +137,15 @@ UpSnap offers unique access for each user, per device. While admins have all per
Although UpSnap has user authorisation, it is **not recommended to expose it to the open web** and make it accessible by everyone!
**Reason**: The shutdown device command is basically a command piped to #sh (root if you run docker). If anyone gains unauthorized access and can abuse this api route in any way, the attacker has access to a (root) shell on your local network.
**Reason**: The shutdown device command is basically a command piped to #sh (possibly as root user). If anyone gains unauthorized access and can abuse this API route in any way, the attacker has access to a (root) shell on your local network.
**Recommended**: If you need access from outside your network, please use a vpn. Wireguard or OpenVPN is your way to go.
**Recommended**: If you need access from outside your network, please use a VPN. Wireguard or OpenVPN is your way to go.
## 🌐 Help translating
UpSnap is available in the following languages so far:
- 🇸🇦 **Arabic (Saudi Arabia)** (ar-SA)
- 🇧🇬 **Bulgarian (Bulgaria)** (bg-BG)
- 🇨🇿 **Czech (Czech republic)** (cs-CZ)
- 🇩🇪 **German (Germany)** (de-DE)
@@ -181,6 +156,7 @@ UpSnap is available in the following languages so far:
- 🇮🇩 **Bahasa (Indonesia)** (id-ID)
- 🇮🇹 **Italian (Italy)** (it-IT)
- 🇯🇵 **Japanese (Japan)** (ja-JP)
- 🇰🇷 **Korean (Republic of Korea)** (ko-KR)
- 🇳🇱 **Dutch (Netherlands)** (nl-NL)
- 🇳🇴 **Norwegian (Norway)** (nb-NO)
- 🇵🇱 **Polish (Poland)** (pl-PL)
+2 -2
View File
@@ -132,7 +132,7 @@ func SetWakeShutdownJobs(app *pocketbase.PocketBase) {
if d.GetString("status") == "pending" {
return
}
isOnline, err := networking.PingDevice(dev)
isOnline, err := networking.PingDevice(d)
if err != nil {
logger.Error.Println(err)
return
@@ -170,7 +170,7 @@ func SetWakeShutdownJobs(app *pocketbase.PocketBase) {
if d.GetString("status") == "pending" {
return
}
isOnline, err := networking.PingDevice(dev)
isOnline, err := networking.PingDevice(d)
if err != nil {
logger.Error.Println(err)
return
+6 -7
View File
@@ -1,11 +1,11 @@
module github.com/seriousm4x/upsnap
go 1.25.0
go 1.26.1
require (
github.com/mdlayher/wol v0.0.0-20220221231636-b763a792253a
github.com/pocketbase/dbx v1.12.0
github.com/pocketbase/pocketbase v0.36.7
github.com/pocketbase/pocketbase v0.36.8
github.com/prometheus-community/pro-bing v0.8.0
github.com/robfig/cron/v3 v3.0.1
golang.org/x/sys v0.42.0
@@ -17,13 +17,12 @@ require (
github.com/disintegration/imaging v1.6.2 // indirect
github.com/domodwyer/mailyak/v3 v3.6.2 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/fatih/color v1.18.0 // indirect
github.com/fatih/color v1.19.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.13 // indirect
github.com/ganigeorgiev/fexpr v0.5.0 // indirect
github.com/go-ozzo/ozzo-validation/v4 v4.3.0 // indirect
github.com/go-sql-driver/mysql v1.9.3 // indirect
github.com/golang-jwt/jwt/v5 v5.3.1 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/native v1.1.0 // indirect
@@ -31,7 +30,7 @@ require (
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mdlayher/ethernet v0.0.0-20220221185849-529eae5b6118 // indirect
github.com/mdlayher/packet v1.1.2 // indirect
github.com/mdlayher/socket v0.5.1 // indirect
github.com/mdlayher/socket v0.6.0 // indirect
github.com/ncruces/go-strftime v1.0.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/spf13/cast v1.10.0 // indirect
@@ -39,7 +38,7 @@ require (
github.com/spf13/pflag v1.0.10 // indirect
github.com/stretchr/testify v1.11.1 // indirect
golang.org/x/crypto v0.49.0 // indirect
golang.org/x/image v0.37.0 // indirect
golang.org/x/image v0.38.0 // indirect
golang.org/x/net v0.52.0 // indirect
golang.org/x/oauth2 v0.36.0 // indirect
golang.org/x/sync v0.20.0 // indirect
@@ -48,5 +47,5 @@ require (
modernc.org/libc v1.70.0 // indirect
modernc.org/mathutil v1.7.1 // indirect
modernc.org/memory v1.11.0 // indirect
modernc.org/sqlite v1.46.2 // indirect
modernc.org/sqlite v1.48.0 // indirect
)
+10 -10
View File
@@ -13,8 +13,8 @@ github.com/domodwyer/mailyak/v3 v3.6.2 h1:x3tGMsyFhTCaxp6ycgR0FE/bu5QiNp+hetUuCO
github.com/domodwyer/mailyak/v3 v3.6.2/go.mod h1:lOm/u9CyCVWHeaAmHIdF4RiKVxKUT/H5XX10lIKAL6c=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
github.com/fatih/color v1.19.0 h1:Zp3PiM21/9Ld6FzSKyL5c/BULoe/ONr9KlbYVOfG8+w=
github.com/fatih/color v1.19.0/go.mod h1:zNk67I0ZUT1bEGsSGyCZYZNrHuTkJJB+r6Q9VuMi0LE=
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/gabriel-vasile/mimetype v1.4.13 h1:46nXokslUBsAJE/wMsp5gtO500a4F3Nkz9Ufpk2AcUM=
@@ -61,8 +61,8 @@ github.com/mdlayher/packet v1.1.2 h1:3Up1NG6LZrsgDVn6X4L9Ge/iyRyxFEFD9o6Pr3Q1nQY
github.com/mdlayher/packet v1.1.2/go.mod h1:GEu1+n9sG5VtiRE4SydOmX5GTwyyYlteZiFU+x0kew4=
github.com/mdlayher/raw v0.0.0-20190313224157-43dbcdd7739d/go.mod h1:r1fbeITl2xL/zLbVnNHFyOzQJTgr/3fpf1lJX/cjzR8=
github.com/mdlayher/socket v0.2.1/go.mod h1:QLlNPkFR88mRUNQIzRBMfXxwKal8H7u1h3bL1CV+f0E=
github.com/mdlayher/socket v0.5.1 h1:VZaqt6RkGkt2OE9l3GcC6nZkqD3xKeQLyfleW/uBcos=
github.com/mdlayher/socket v0.5.1/go.mod h1:TjPLHI1UgwEv5J1B5q0zTZq12A/6H7nKmtTanQE37IQ=
github.com/mdlayher/socket v0.6.0 h1:ScZPaAGyO1icQnbFrhPM8mnXyMu9qukC1K4ZoM2IQKU=
github.com/mdlayher/socket v0.6.0/go.mod h1:q7vozUAnxSqnjHc12Fik5yUKIzfZ8ITCfMkhOtE9z18=
github.com/mdlayher/wol v0.0.0-20220221231636-b763a792253a h1:fpQi42PM6HzbHwNg6a7OvLbh5l49Rgr7GCARozjHwio=
github.com/mdlayher/wol v0.0.0-20220221231636-b763a792253a/go.mod h1:XX6nvyQpGc8E4KaQm62FyexOYd36ilpyfYf8wjgMDV8=
github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w=
@@ -71,8 +71,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pocketbase/dbx v1.12.0 h1:/oLErM+A0b4xI0PWTGPqSDVjzix48PqI/bng2l0PzoA=
github.com/pocketbase/dbx v1.12.0/go.mod h1:xXRCIAKTHMgUCyCKZm55pUOdvFziJjQfXaWKhu2vhMs=
github.com/pocketbase/pocketbase v0.36.7 h1:MrViB7BptPYrf2Nt25pJEYBqUdFjuhRKu1p5GTrkvPA=
github.com/pocketbase/pocketbase v0.36.7/go.mod h1:qX4HuVjoKXtEg41fSJVM0JLfGWXbBmHxVv/FaE446r4=
github.com/pocketbase/pocketbase v0.36.8 h1:gCNqoesZ44saYOD3J7edhi5nDwUWKyQG7boM/kVwz2c=
github.com/pocketbase/pocketbase v0.36.8/go.mod h1:OY4WaXbP0WnF/EXoBbboWJK+ZSZ1A85tiA0sjrTKxTA=
github.com/prometheus-community/pro-bing v0.8.0 h1:CEY/g1/AgERRDjxw5P32ikcOgmrSuXs7xon7ovx6mNc=
github.com/prometheus-community/pro-bing v0.8.0/go.mod h1:Idyxz8raDO6TgkUN6ByiEGvWJNyQd40kN9ZUeho3lN0=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
@@ -98,8 +98,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.49.0 h1:+Ng2ULVvLHnJ/ZFEq4KdcDd/cfjrrjjNSXNzxg0Y4U4=
golang.org/x/crypto v0.49.0/go.mod h1:ErX4dUh2UM+CFYiXZRTcMpEcN8b/1gxEuv3nODoYtCA=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.37.0 h1:ZiRjArKI8GwxZOoEtUfhrBtaCN+4b/7709dlT6SSnQA=
golang.org/x/image v0.37.0/go.mod h1:/3f6vaXC+6CEanU4KJxbcUZyEePbyKbaLoDOe4ehFYY=
golang.org/x/image v0.38.0 h1:5l+q+Y9JDC7mBOMjo4/aPhMDcxEptsX+Tt3GgRQRPuE=
golang.org/x/image v0.38.0/go.mod h1:/3f6vaXC+6CEanU4KJxbcUZyEePbyKbaLoDOe4ehFYY=
golang.org/x/mod v0.33.0 h1:tHFzIWbBifEmbwtGz65eaWyGiGZatSrT9prnU8DbVL8=
golang.org/x/mod v0.33.0/go.mod h1:swjeQEj+6r7fODbD2cqrnje9PnziFuw4bmLbBZFrQ5w=
golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
@@ -158,8 +158,8 @@ modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8=
modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
modernc.org/sqlite v1.46.2 h1:gkXQ6R0+AjxFC/fTDaeIVLbNLNrRoOK7YYVz5BKhTcE=
modernc.org/sqlite v1.46.2/go.mod h1:hWjRO6Tj/5Ik8ieqxQybiEOUXy0NJFNp2tpvVpKlvig=
modernc.org/sqlite v1.48.0 h1:ElZyLop3Q2mHYk5IFPPXADejZrlHu7APbpB0sF78bq4=
modernc.org/sqlite v1.48.0/go.mod h1:hWjRO6Tj/5Ik8ieqxQybiEOUXy0NJFNp2tpvVpKlvig=
modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
+1 -1
View File
@@ -25,7 +25,7 @@ func TestPingDevice(t *testing.T) {
name: "Invalid Ping Command",
ip: "8.8.8.8",
ping_cmd: "exit 1",
wantError: true,
wantError: false,
},
}
+7 -1
View File
@@ -74,6 +74,12 @@ func PingDevice(device *core.Record) (bool, error) {
cmd := exec.Command(shell, shell_arg, ping_cmd)
err := cmd.Run()
return err == nil, err
if err != nil {
if _, ok := err.(*exec.ExitError); ok {
return false, nil
}
return false, err
}
return true, nil
}
}
+7 -1
View File
@@ -60,6 +60,12 @@ func PingDevice(device *core.Record) (bool, error) {
cmd := exec.Command(shell, shell_arg, ping_cmd)
err := cmd.Run()
return err == nil, err
if err != nil {
if _, ok := err.(*exec.ExitError); ok {
return false, nil
}
return false, err
}
return true, nil
}
}
+14 -6
View File
@@ -48,6 +48,7 @@ func WakeDevice(device *core.Record) error {
if err := cmd.Start(); err != nil {
logger.Error.Println(err)
return err
}
done := make(chan error, 1)
@@ -61,8 +62,10 @@ func WakeDevice(device *core.Record) error {
select {
case <-time.After(1 * time.Second):
if time.Since(start) >= time.Duration(wakeTimeout)*time.Second {
if err := KillProcess(cmd.Process); err != nil {
logger.Error.Println(err)
if cmd.Process != nil {
if err := KillProcess(cmd.Process); err != nil {
logger.Error.Println(err)
}
}
return fmt.Errorf("%s not online after %d seconds", device.GetString("name"), wakeTimeout)
}
@@ -72,18 +75,23 @@ func WakeDevice(device *core.Record) error {
return err
}
if isOnline {
if err := KillProcess(cmd.Process); err != nil {
logger.Error.Println(err)
if cmd.Process != nil {
if err := KillProcess(cmd.Process); err != nil {
// Process might have already finished
}
}
return nil
}
case err := <-done:
if err != nil {
if err := KillProcess(cmd.Process); err != nil {
logger.Error.Println(err)
if cmd.Process != nil {
if err := KillProcess(cmd.Process); err != nil {
logger.Error.Println(err)
}
}
return fmt.Errorf("%s", stderr.String())
}
// Command finished successfully, but we continue the loop until device is online or timeout
}
}
} else {
+8 -1
View File
@@ -118,12 +118,19 @@ func StartPocketBase(distDirFS fs.FS) {
oldShutdownCmd := oldRecord.GetString("shutdown_cmd")
oldShutdownCronEnabled := oldRecord.GetBool("shutdown_cron_enabled")
newIp := newRecord.GetString("ip")
oldIp := oldRecord.GetString("ip")
newPingCmd := newRecord.GetString("ping_cmd")
oldPingCmd := oldRecord.GetString("ping_cmd")
if newWakeCron != oldWakeCron ||
newWakeCmd != oldWakeCmd ||
newWakeCronEnabled != oldWakeCronEnabled ||
newShutdownCron != oldShutdownCron ||
newShutdownCronEnabled != oldShutdownCronEnabled ||
newShutdownCmd != oldShutdownCmd {
newShutdownCmd != oldShutdownCmd ||
newIp != oldIp ||
newPingCmd != oldPingCmd {
cronjobs.SetWakeShutdownJobs(app)
}
}
+1 -3
View File
@@ -1,7 +1,7 @@
services:
upsnap:
cap_add:
- NET_RAW # NET_RAW is required for privileged ping
- NET_RAW # NET_RAW is required for privileged ping and network device scan (nmap)
cap_drop:
- ALL
container_name: upsnap
@@ -28,5 +28,3 @@ services:
# dns:
# - 192.18.0.1
# - 192.18.0.2
# # or install custom packages for shutdown
# entrypoint: /bin/sh -c "apk update && apk add --no-cache <YOUR_PACKAGE> && rm -rf /var/cache/apk/* && ./upsnap serve"
+4 -4
View File
@@ -25,18 +25,18 @@
"daisyui": "^5.5.19",
"eslint": "^10.1.0",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-svelte": "^3.15.2",
"eslint-plugin-svelte": "^3.16.0",
"globals": "^17.4.0",
"husky": "^9.1.7",
"prettier": "^3.8.1",
"prettier-plugin-svelte": "^3.5.1",
"prettier-plugin-tailwindcss": "^0.7.2",
"svelte": "^5.54.0",
"svelte-check": "^4.4.5",
"svelte": "^5.55.1",
"svelte-check": "^4.4.6",
"tailwindcss": "^4.2.2",
"tslib": "^2.8.1",
"typescript": "^5.9.3",
"typescript-eslint": "^8.57.1",
"typescript-eslint": "^8.58.0",
"vite": "^7.3.1"
},
"type": "module",
+705 -1512
View File
File diff suppressed because it is too large Load Diff