From 08c725a4f416a6a1df01367797ef3f65f6ebdf95 Mon Sep 17 00:00:00 2001 From: EkkoG Date: Fri, 10 May 2024 17:48:17 +0800 Subject: [PATCH] Support user_modules --- .gitignore | 4 ++-- build.sh | 58 ++++++++++++++++++++++++++++++++---------------------- run.sh | 3 ++- 3 files changed, 38 insertions(+), 27 deletions(-) diff --git a/.gitignore b/.gitignore index ee45730..1119046 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,6 @@ bin/ .DS_Store transfer.sh -modules/z-* +user_modules docker-compose.yml -_run.sh \ No newline at end of file +_run.sh diff --git a/build.sh b/build.sh index dd84cb6..d88d3c2 100755 --- a/build.sh +++ b/build.sh @@ -23,36 +23,46 @@ for module in $MODULES; do done final_modules="$(echo "$final_modules" | tr '\n' ' ')" echo "Final modules: $final_modules" -cp -r custom_modules modules +cp -r modules_in_container modules +cp -r user_modules_in_container user_modules -for module in $final_modules; do +all_packages= - if [ -f "modules/$module/packages" ]; then - all_packages="$all_packages $(cat modules/$module/packages)" - fi +deal() { + modules_dir=$1 + + for module in $final_modules; do + + if [ -f "$modules_dir/$module/packages" ]; then + all_packages="$all_packages $(cat $modules_dir/$module/packages)" + fi - if [ -f "modules/$module/.env" ]; then - . modules/$module/.env - for file in $(find "modules/$module/files/etc/uci-defaults" -type f); do - all_env="$(cat modules/$module/.env)" - for env in $all_env; do - env_name="$(echo "$env" | cut -d '=' -f 1)" - env_value="${!env_name}" - sed -e "s|\$$env_name|$env_value|g" -i $file + if [ -f "$modules_dir/$module/.env" ]; then + . $modules_dir/$module/.env + for file in $(find "$modules_dir/$module/files/etc/uci-defaults" -type f); do + all_env="$(cat $modules_dir/$module/.env)" + for env in $all_env; do + env_name="$(echo "$env" | cut -d '=' -f 1)" + env_value="${!env_name}" + sed -e "s|\$$env_name|$env_value|g" -i $file + done done - done - fi + fi - if [ -d "modules/$module/files" ]; then - mkdir -p files - cp -r modules/$module/files/** files/ - fi + if [ -d "$modules_dir/$module/files" ]; then + mkdir -p files + cp -r $modules_dir/$module/files/** files/ + fi - if [ -f "modules/$module/post-files.sh" ]; then - echo "Running post-files.sh for $module" - . modules/$module/post-files.sh - fi -done + if [ -f "$modules_dir/$module/post-files.sh" ]; then + echo "Running post-files.sh for $module" + . $modules_dir/$module/post-files.sh + fi + done +} + +deal modules +deal user_modules echo "All packages: $all_packages" diff --git a/run.sh b/run.sh index 937e82b..68e2435 100755 --- a/run.sh +++ b/run.sh @@ -91,7 +91,8 @@ services: volumes: - ./bin:$BUILD_DIR/bin - ./build.sh:$BUILD_DIR/build.sh - - ./modules:$BUILD_DIR/custom_modules + - ./modules:$BUILD_DIR/modules_in_container + - ./user_modules:$BUILD_DIR/user_modules_in_container - ./.env:$BUILD_DIR/.env command: "./build.sh" END