try fix docker mount problem
This commit is contained in:
parent
3d301a4f15
commit
920339e94c
6 changed files with 16 additions and 99 deletions
|
@ -2,9 +2,8 @@ services:
|
|||
magma:
|
||||
container_name: magma
|
||||
image: help14/magma
|
||||
restart: always
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./common:/app/common
|
||||
#- ./themes/custom:/app/themes/custom
|
||||
- ./data/:/app/data
|
||||
ports:
|
||||
- '7001:7001'
|
||||
- '7001:7001'
|
18
src/main.go
18
src/main.go
|
@ -1,7 +1,6 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"html/template"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
|
@ -30,7 +29,7 @@ func main() {
|
|||
websiteData.Language = modules.LoadLanguage(appConfig.Website.Language)
|
||||
websiteData.Contents = modules.LoadContent().Data
|
||||
|
||||
commonfs := http.FileServer(http.Dir(filepath.Join(pwd, "common")))
|
||||
commonfs := http.FileServer(http.Dir(filepath.Join(pwd, "data")))
|
||||
http.Handle("/common/", http.StripPrefix("/common/", commonfs))
|
||||
|
||||
languagefs := http.FileServer(http.Dir(filepath.Join(pwd, "languages")))
|
||||
|
@ -78,16 +77,7 @@ func serveTemplate(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
func prepareSampleFiles() {
|
||||
files, err := ioutil.ReadDir(filepath.Join(pwd, "sample"))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
return
|
||||
}
|
||||
for _, file := range files {
|
||||
samplePath := filepath.Join(pwd, "sample", file.Name())
|
||||
commonPath := filepath.Join(pwd, "common", file.Name())
|
||||
if _, err := os.Stat(commonPath); errors.Is(err, os.ErrNotExist) {
|
||||
modules.CopyFile(samplePath, commonPath)
|
||||
}
|
||||
}
|
||||
commonPath := filepath.Join(pwd, "common")
|
||||
dataPath := filepath.Join(pwd, "data")
|
||||
modules.CopyDirectory(commonPath, dataPath)
|
||||
}
|
||||
|
|
|
@ -4,9 +4,10 @@ import (
|
|||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
func CopyFile(src string, dst string) {
|
||||
func CopyFile(src, dst string) {
|
||||
fin, err := os.Open(src)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
@ -25,3 +26,8 @@ func CopyFile(src string, dst string) {
|
|||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func CopyDirectory(oldDir, newDir string) {
|
||||
cmd := exec.Command("cp", "--recursive", oldDir, newDir)
|
||||
cmd.Run()
|
||||
}
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
website:
|
||||
theme: "flame"
|
||||
title: "Magma Dashboard"
|
||||
description: ""
|
||||
language: "en"
|
||||
localization: "en-US"
|
||||
useMetric: true
|
||||
openweathermap:
|
||||
apiKey:
|
||||
lon:
|
||||
lat:
|
||||
addons:
|
|
@ -1,67 +0,0 @@
|
|||
data:
|
||||
- title: Applications
|
||||
columns:
|
||||
- title: Servers
|
||||
bookmarks:
|
||||
- name: OpenWRT
|
||||
icon: fa-solid fa-wifi
|
||||
url: https://openwrt.org
|
||||
- name: Proxmox
|
||||
icon: fa-solid fa-rectangle-xmark
|
||||
url: https://www.proxmox.com/en/
|
||||
- name: Home Assistant
|
||||
icon: fa-solid fa-house
|
||||
url: https://www.home-assistant.io
|
||||
- name: Docker
|
||||
icon: fa-brands fa-docker
|
||||
url: https://www.docker.com
|
||||
- title: Nas
|
||||
bookmarks:
|
||||
- name: TrueNas
|
||||
icon: fa-solid fa-server
|
||||
url: https://www.truenas.com
|
||||
- name: Kerberos
|
||||
icon: fa-solid fa-video
|
||||
url: https://kerberos.io
|
||||
- name: jDownloader
|
||||
icon: fa-solid fa-cloud-arrow-down
|
||||
url: https://jdownloader.org
|
||||
- title: Monitoring
|
||||
bookmarks:
|
||||
- name: Grafana
|
||||
icon: fa-solid fa-server
|
||||
url: https://grafana.com
|
||||
- name: InfluxDb
|
||||
icon: fa-solid fa-database
|
||||
url: https://www.influxdata.com
|
||||
- title: Tools
|
||||
bookmarks:
|
||||
- name: Bitwarden
|
||||
icon: fa-solid fa-shield-halved
|
||||
url: https://bitwarden.com
|
||||
- title: Bookmarks
|
||||
columns:
|
||||
- title: Social Media
|
||||
bookmarks:
|
||||
- name: Facebook
|
||||
icon: fa-brands fa-facebook
|
||||
url: https://www.facebook.com
|
||||
- name: Reddit
|
||||
icon: fa-brands fa-reddit
|
||||
url: https://www.reddit.com
|
||||
- name: Youtube
|
||||
icon: fa-brands fa-youtube
|
||||
url: https://www.youtube.com
|
||||
- title: Shopping
|
||||
bookmarks:
|
||||
- name: Shopee
|
||||
icon: fa-solid fa-bag-shopping
|
||||
url: https://shopee.vn
|
||||
- name: Lazada
|
||||
icon: fa-brands fa-amazon
|
||||
url: https://www.amazon.com
|
||||
- title: Tools
|
||||
bookmarks:
|
||||
- name: Maps
|
||||
icon: fa-solid fa-map
|
||||
url: https://www.google.com/maps
|
|
@ -8,7 +8,7 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<link rel="icon" type="image/png" href="/common/assets/favicon.ico" />
|
||||
|
||||
|
||||
<link rel="stylesheet" href="/theme/css/font.css">
|
||||
<link rel="stylesheet" href="/theme/css/normalize.min.css">
|
||||
<link rel="stylesheet" href="/theme/css/skeleton.min.css">
|
||||
|
@ -103,6 +103,7 @@
|
|||
(async function loadWeather() {
|
||||
// Get info from api
|
||||
const weather = await (await fetch("./weather")).json();
|
||||
if(!weather) return;
|
||||
// Parse weather id
|
||||
let icon = null;
|
||||
let isDay = Date.now().hour >= 6 && Date.now().hour < 18;
|
||||
|
|
Loading…
Add table
Reference in a new issue