feature: entities wip (#226)

This commit is contained in:
James Read 2024-02-07 10:36:57 +01:00 committed by GitHub
parent 759e747f54
commit 5b0cfb5c33
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 112 additions and 80 deletions

View File

@ -8,90 +8,104 @@ listenAddressSingleHTTPFrontend: 0.0.0.0:1337
# Choose from INFO (default), WARN and DEBUG # Choose from INFO (default), WARN and DEBUG
logLevel: "INFO" logLevel: "INFO"
entities:
- name: container
file: /etc/OliveTin/entities/containers.yaml
icon: container
helpers:
- title: refresh container file
shell: "docker ps --format '{{ .state }}' > /etc/OliveTin/entities/containers.yaml"
execOnStartup: true
execOnCron:
- "*/1 * * * * *"
# Actions (buttons) to show up on the WebUI: # Actions (buttons) to show up on the WebUI:
actions: actions:
- title: date - title: date
shell: date shell: date
icon: clock icon: clock
popupOnStart: true popupOnStart: true
# This will run a simple script that you create. - title: start
- title: Run backup script shell: docker start {{ container.name }}
shell: /opt/backupScript.sh icon: start
shellAfterCompleted: "apprise -t 'Notification: Backup script completed' -b 'The backup script completed with code {{ exitCode}}. The log is: \n {{ stdout }} '" entity: container
maxConcurrent: 1
icon: backup
execOnCron: # https://docs.olivetin.app/exec-cron.html
- "@monthly" # Once per month
- "0 12 25 12 *" # And on Christmas day!
# This will send 1 ping (-c 1) # This will run a simple script that you create.
# Docs: https://docs.olivetin.app/action-ping.html - title: Run backup script
- title: Ping host shell: /opt/backupScript.sh
shell: ping {{ host }} -c {{ count }} shellAfterCompleted: "apprise -t 'Notification: Backup script completed' -b 'The backup script completed with code {{ exitCode}}. The log is: \n {{ stdout }} '"
icon: ping maxConcurrent: 1
timeout: 100 icon: backup
arguments:
- name: host
title: host
type: ascii_identifier
default: example.com
description: The host that you want to ping
- name: count # This will send 1 ping (-c 1)
title: Count # Docs: https://docs.olivetin.app/action-ping.html
type: int - title: Ping host
default: 1 shell: ping {{ host }} -c {{ count }}
description: How many times to do you want to ping? icon: ping
timeout: 100
arguments:
- name: host
title: host
type: ascii_identifier
default: example.com
description: The host that you want to ping
# Restart lightdm on host "server1" - name: count
# Docs: https://docs.olivetin.app/action-ping.html title: Count
- title: restart httpd type: int
titleAlias: restart_httpd default: 1
icon: restart description: How many times to do you want to ping?
shell: ssh root@server1 'service httpd restart'
# OliveTin can run long-running jobs like Ansible playbooks. # Restart lightdm on host "server1"
# # Docs: https://docs.olivetin.app/action-ping.html
# For such jobs, you will need to install ansible-playbook on the host where - title: restart httpd
# you are running OliveTin, or in the container. titleAlias: restart_httpd
# icon: restart
# You probably want a much longer timeout as well (so that ansible completes). shell: ssh root@server1 'service httpd restart'
- title: "Run Ansible Playbook"
icon: "&#x1F1E6"
shell: ansible-playbook -i /etc/hosts /root/myRepo/myPlaybook.yaml
timeout: 120
# OliveTin can control containers - docker is just a command line app. # OliveTin can run long-running jobs like Ansible playbooks.
# #
# However, if you are running in a container you will need to do some setup, # For such jobs, you will need to install ansible-playbook on the host where
# see the docs below. # you are running OliveTin, or in the container.
# #
# Docs: https://docs.olivetin.app/action-container-control.html # You probably want a much longer timeout as well (so that ansible completes).
- title: Restart Docker Container - title: "Run Ansible Playbook"
icon: restart icon: "&#x1F1E6"
shell: docker restart {{ container }} shell: ansible-playbook -i /etc/hosts /root/myRepo/myPlaybook.yaml
arguments: timeout: 120
- name: container
title: Container name
choices:
- value: plex
- value: traefik
- value: grafana
- title: Slow Script # OliveTin can control containers - docker is just a command line app.
shell: sleep 3 #
timeout: 5 # However, if you are running in a container you will need to do some setup,
icon: "&#x1F971" # see the docs below.
#
# Docs: https://docs.olivetin.app/action-container-control.html
- title: Restart Docker Container
icon: restart
shell: docker restart {{ container }}
arguments:
- name: container
title: Container name
choices:
- value: plex
- value: traefik
- value: grafana
- title: Broken Script (timeout) - title: Slow Script
shell: sleep 5 shell: sleep 3
timeout: 5 timeout: 5
icon: "&#x1F62A" icon: "&#x1F971"
- title: Delete old backups - title: Broken Script (timeout)
icon: ashtonished shell: sleep 5
shell: rm -rf /opt/oldBackups/ timeout: 5
arguments: icon: "&#x1F62A"
- type: confirmation
title: Are you sure?! - title: Delete old backups
icon: ashtonished
shell: rm -rf /opt/oldBackups/
arguments:
- type: confirmation
title: Are you sure?!

View File

@ -12,6 +12,7 @@ type Action struct {
CSS map[string]string `mapstructure:"omitempty"` CSS map[string]string `mapstructure:"omitempty"`
Timeout int Timeout int
Acls []string Acls []string
Entity []string
ExecOnStartup bool ExecOnStartup bool
ExecOnCron []string ExecOnCron []string
ExecOnFileCreatedInDir []string ExecOnFileCreatedInDir []string
@ -37,12 +38,22 @@ type ActionArgumentChoice struct {
Title string Title string
} }
// HelperAction is an action that is used normally to generate entities, it cannot be started manually.
type HelperAction struct {
Title string
Shell string
ExecOnStartup bool
ExecOnCron []string
ExecOnFileCreatedInDir []string
ExecOnFileChangedInDir []string
}
// Entity represents a "thing" that can have multiple actions associated with it. // Entity represents a "thing" that can have multiple actions associated with it.
// for example, a media player with a start and stop action. // for example, a media player with a start and stop action.
type Entity struct { type EntityFile struct {
Title string File string
Name string
Icon string Icon string
Actions []Action `mapstructure:"actions"`
CSS map[string]string CSS map[string]string
} }
@ -72,8 +83,8 @@ type Config struct {
ExternalRestAddress string ExternalRestAddress string
LogLevel string LogLevel string
Actions []Action `mapstructure:"actions"` Actions []Action `mapstructure:"actions"`
Entities []EntityFile `mapstructure:"entities"`
Dashboards []DashboardItem `mapstructure:"dashboards"` Dashboards []DashboardItem `mapstructure:"dashboards"`
Entities []Entity `mapstructure:"entities"`
CheckForUpdates bool CheckForUpdates bool
PageTitle string PageTitle string
ShowFooter bool ShowFooter bool
@ -89,6 +100,7 @@ type Config struct {
DefaultPermissions PermissionsList DefaultPermissions PermissionsList
AccessControlLists []AccessControlList AccessControlLists []AccessControlList
WebUIDir string WebUIDir string
HelperActions []HelperAction `mapstructure:"helperActions"`
CronSupportForSeconds bool CronSupportForSeconds bool
SectionNavigationStyle string SectionNavigationStyle string
} }

View File

@ -0,0 +1,6 @@
sonarr:
state: started
plex:
state: started
sabnzbd:
state: stopped