Skip to content

Commit

Permalink
Support user_modules
Browse files Browse the repository at this point in the history
  • Loading branch information
EkkoG committed May 10, 2024
1 parent 6dc83b6 commit 08c725a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 27 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ bin/
.DS_Store
transfer.sh

modules/z-*
user_modules
docker-compose.yml
_run.sh
_run.sh
58 changes: 34 additions & 24 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
3 changes: 2 additions & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 08c725a

Please sign in to comment.