feature: Helper scripts for ssh, themes, etc (#349)

* feature: Helper scripts for ssh, themes, etc

* cicd: Update goreleaser to support v2 .goreleaser.yml files
This commit is contained in:
James Read 2024-07-07 23:10:33 +01:00 committed by GitHub
parent e0678fc0a9
commit 482ef0e5e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 71 additions and 14 deletions

View File

@ -52,7 +52,7 @@ jobs:
run: cd integration-tests && make -w
- name: goreleaser
uses: goreleaser/goreleaser-action@v5
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest

View File

@ -54,7 +54,7 @@ jobs:
run: make -w webui-dist
- name: goreleaser
uses: goreleaser/goreleaser-action@v5
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest

1
.gitignore vendored
View File

@ -12,3 +12,4 @@ tmp/
webui/
webui.dev/node_modules
webui.dev/.parcel-cache
custom-webui

View File

@ -1,4 +1,5 @@
project_name: OliveTin
version: 2
before:
hooks:
- go mod download
@ -98,7 +99,7 @@ dockers:
- webui
- var/entities/
- config.yaml
- var/helper-actions/olivetin-setup-easy-ssh
- var/helper-actions/
- image_templates:
- "docker.io/jamesread/olivetin:{{ .Tag }}-arm64"
@ -115,7 +116,7 @@ dockers:
- webui
- var/entities/
- config.yaml
- var/helper-actions/olivetin-setup-easy-ssh
- var/helper-actions/
docker_manifests:
- name_template: docker.io/jamesread/olivetin:{{ .Version }}

View File

@ -11,6 +11,7 @@ RUN mkdir -p /config /config/entities/ /var/www/olivetin \
shadow-utils \
apprise \
jq \
git \
docker \
&& microdnf clean all
@ -24,7 +25,7 @@ VOLUME /config
COPY OliveTin /usr/bin/OliveTin
COPY webui /var/www/olivetin/
COPY var/helper-actions/olivetin-setup-easy-ssh /usr/bin/olivetin-setup-easy-ssh
COPY var/helper-actions/* /usr/bin/
USER olivetin

View File

@ -11,6 +11,7 @@ RUN mkdir -p /config /config/entities/ /var/www/olivetin \
shadow-utils \
apprise \
jq \
git \
docker \
&& microdnf clean all
@ -24,7 +25,7 @@ VOLUME /config
COPY OliveTin /usr/bin/OliveTin
COPY webui /var/www/olivetin/
COPY var/helper-actions/olivetin-setup-easy-ssh /usr/bin/olivetin-setup-easy-ssh
COPY var/helper-actions/* /usr/bin/
USER olivetin

View File

@ -20,7 +20,7 @@ VOLUME /config
COPY OliveTin /usr/bin/OliveTin
COPY webui /var/www/olivetin/
COPY var/helper-actions/olivetin-setup-easy-ssh /usr/bin/olivetin-setup-easy-ssh
COPY var/helper-actions/* /usr/bin/
USER olivetin

View File

@ -5,7 +5,6 @@
# Listen on all addresses available, port 1337
listenAddressSingleHTTPFrontend: 0.0.0.0:1337
# Choose from INFO (default), WARN and DEBUG
logLevel: "INFO"
@ -111,17 +110,44 @@ actions:
- type: confirmation
title: Are you sure?!
# This is an action that runs a script included with OliveTin, that will
# download themes. You will still need to set theme "themeName" in your config.
#
# Docs: https://docs.olivetin.app/themes.html
- title: Get OliveTin Theme
shell: olivetin-get-theme {{ themeGitRepo }} {{ themeFolderName }}
icon: theme
arguments:
- name: themeGitRepo
title: Theme's Git Repository
description: Find new themes at https://olivetin.app/themes
type: url
- name: themeFolderName
title: Theme's Folder Name
type: ascii_identifier
# Sometimes you want to run actions on other servers - don't overcomplicate
# it, just use SSH!
# it, just use SSH! OliveTin includes a helper to make this easier, which is
# entirely optional. You can also setup SSH manually.
#
# Docs: https://docs.olivetin.app/action-ssh-easy.html
# Docs: https://docs.olivetin.app/action-ssh.html
- title: "Setup easy SSH"
icon: ssh
shell: olivetin-setup-easy-ssh
popupOnStart: execution-dialog
# Here's how to use SSH with the "easy" config, to restart a service on
# another server.
#
# Docs: https://docs.olivetin.app/action-ssh-easy.html
# Docs: https://docs.olivetin.app/action-service.html
- title: Restart httpd on server1
id: restart_httpd
icon: restart
timeout: 1
shell: ssh root@server1 'service httpd restart'
shell: ssh -F /config/ssh/easy.cg root@server1 'service httpd restart'
# Lots of people use OliveTin to build web interfaces for their electronics
# projects. It's best to install OliveTin as a native package (eg, .deb), and
@ -272,3 +298,4 @@ dashboards:
- title: 'Start {{ container.Names }}'
- title: 'Stop {{ container.Names }}'
themeName: buttonbox

View File

@ -14,6 +14,8 @@ var emojis = map[string]string{
"logs": "🔍",
"light": "💡",
"robot": "🤖",
"ssh": "🔐",
"theme": "🎨",
}
func lookupHTMLIcon(keyToLookup string, defaultIcon string) string {

View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
olivetin-get-git-repo "https://github.com/walkxcode/dashboard-icons.git" /config/custom-webui/dashboard-icons/

View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
REPO=$1
DEST=$2
git -C "$DEST" pull || git clone "$REPO" "$DEST"

View File

@ -0,0 +1,12 @@
#!/usr/bin/env bash
olivetin-get-git-repo "$1" "/config/custom-webui/themes/$2"
if grep -E -q "^themeName" /config/config.yaml; then
echo "Updating theme in config file"
sed -i "s/^themeName:.*/themeName: $2/g" /config/config.yaml
else
echo "themeName: $2" >> /config/config.yaml
fi
echo "You must restart OliveTin for theme changes to take effect."

View File

@ -18,13 +18,16 @@ echo "To use this SSH key with OliveTin, format your action line like this:"
echo ""
echo "actions:"
echo " - name: My SSH Action"
echo " shell: ssh -F /config/ssh/config user@host \"echo 'Hello, world!'\""
echo " shell: ssh -F /config/ssh/easy.cfg user@host \"echo 'Hello, world!'\""
echo ""
echo "Note: This config has ssh key checking turned off for convenience."
echo "If validating SSH keys is important to you, you should not use this config."
echo "Note: This config has ssh key checking turned off so you don't have to "
echo "keep approving host keys inside the OliveTin container. This should only"
echo "be used in environments where checking SSH host keys is not important."
echo ""
echo "If validating SSH host keys is important, you should not use this config."
echo ""
cat <<EOF > /config/ssh/config
cat <<EOF > /config/ssh/easy.cfg
Host *
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null