kickstart/lib/kickstart-compile
Bruno Tavares e60e0bbebf Fix module loading logic
Modules are located on the `modules` folder on the project.
By default, kickstart will put itself on the `compile/modules/kickstart`
before any folder is linked there as well. This give the possibility of
overriding which kickstart project will be deployed with you.

Kickstart is treated as an special folder, given that the projects
requires its functions. So, it is loaded before all of the modules, and
skiped looping over the `modules` folder.
2014-02-23 12:48:33 -03:00

54 lines
988 B
Bash
Executable File

#!/bin/bash -e
module_loading=$(cat <<MODULE
current_dir=\$(pwd)
cd modules/kickstart
source install.sh
cd \$current_dir
for module in modules/*; do
if [ ! \$module = module/kickstart ]; then
cd \$module
source install.sh
cd \$current_dir
fi
done
MODULE
)
clean_up_compile_folder() {
[ -d compile ] && rm -rf compile
mkdir -p compile
}
link_folder() {
[[ -h compile/$1 ]] || ln -s ../$1 compile/$1
}
link_modules() {
mkdir -p compile/modules
ln -s `kickstart root-dir`/kickstart compile/modules/kickstart
if [ -d modules ]; then
for module in modules/*; do
ln -s `pwd`/$module compile/$module
done
fi
}
compile_install() {
cat <( echo -e "$module_loading" ) install.sh > compile/install.sh
for role in $@; do
echo "source roles/${role}.sh" >> compile/install.sh
done
}
clean_up_compile_folder
link_folder files
link_folder recipes
link_folder roles
link_modules
compile_install $@
echo -e "\necho Done" >> compile/install.sh