From bf74ff705748db503978e0564621986503e7715a Mon Sep 17 00:00:00 2001 From: billz Date: Wed, 25 Dec 2024 12:27:47 -0800 Subject: [PATCH] Update w/ config, plugin actions --- installers/plugin_helper.sh | 49 ++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/installers/plugin_helper.sh b/installers/plugin_helper.sh index 1a99d20c..08c424a3 100755 --- a/installers/plugin_helper.sh +++ b/installers/plugin_helper.sh @@ -7,6 +7,8 @@ # Exit on error set -o errexit +readonly raspap_user="www-data" + [ $# -lt 1 ] && { echo "Usage: $0 [parameters...]"; exit 1; } action="$1" # action to perform @@ -58,13 +60,54 @@ case "$action" in echo "OK" ;; + "config") + [ $# -lt 2 ] && { echo "Usage: $0 config "; exit 1; } + + source=$1 + destination=$2 + + if [ ! -f "$source" ]; then + echo "Source file $source does not exist." + exit 1 + fi + + mkdir -p "$(dirname "$destination")" + cp "$source" "$destination" + + echo "OK" + ;; + + "plugin") + [ $# -lt 2 ] && { echo "Usage: $0 plugin "; exit 1; } + + source=$1 + destination=$2 + + if [ ! -d "$source" ]; then + echo "Source directory $source does not exist." + exit 1 + fi + + plugin_dir=$(dirname "$destination") + if [ ! -d "$lugin_dir" ]; then + mkdir -p "$plugin_dir" + fi + + cp -R "$source" "$destination" + chown -R $raspap_user:$raspap_user "$plugin_dir" + + echo "OK" + ;; + *) echo "Invalid action: $action" echo "Usage: $0 [parameters...]" echo "Actions:" - echo " sudoers Install a sudoers file" - echo " packages Install APT package(s)" - echo " user Add user non-interactively" + echo " sudoers Install a sudoers file" + echo " packages Install aptitude package(s)" + echo " user Add user non-interactively" + echo " config Applies a config file" + echo " plugin Copies a plugin directory" exit 1 ;; esac