Commit a8db555c authored by Heinz N. Gies's avatar Heinz N. Gies

Improve init scripts

parent aa03087f
Pipeline #12501795 passed with stage
in 2 minutes and 16 seconds
......@@ -43,4 +43,15 @@ This calls and the arguments can take placeholders:
* `{brand_root}` - root of this brand
* `{hostname}` - hostname of the jail
An example can be found in the `jail` or `lx-jail` folders
\ No newline at end of file
An example can be found in the `jail` or `lx-jail` folders.
There are two well defined directories in a jail:
- `/jail` the root jail
- `/config`
The `/config` directoy might hold the following files:
- `/config/resolvers` configured resolvers one resolver per line
- `/config/root_authorized_keys` - authorized ssh keys for the root user
- `/config/user_script` - a script the user has asked to be executed on boot
......@@ -42,28 +42,13 @@ done
# install the branch information
mkdir -p ${jail_root}/root$(dirname ${brand_root})
cp -r ${brand_root} ${jail_root}/root$(dirname ${brand_root})
install_brand_files ${brand_root} ${jail_root}
mkdir -p ${jail_root}/root$(dirname ${brand_root})/../shared
cp -r ${brand_root} ${jail_root}/root$(dirname ${brand_root})/../shared
install_etc_resolv_conf ${jail_root}
install_authorized_keys ${jail_root}
if [ -f "${jail_root}/root/config/resolvers" ]
then
for r in $(cat "${jail_root}/root/config/resolvers")
do
echo "nameserver ${r}" >> ${jail_root}/root/jail/etc/resolv.conf
done
fi
if [ -f "${jail_root}/root/config/root_authorized_keys" ]
then
mkdir -p "${jail_root}/root/jail/root/.ssh"
cp "${jail_root}/root/config/root_authorized_keys" "${jail_root}/root/jail/root/.ssh/authorized_keys"
fi
#TODO: network config:
# * get resolvers and set them resolvers
# * routs? (do we need to set them?)
#TODO: get rood autorized keys set set them
......@@ -41,10 +41,12 @@ done
# install the branch information
mkdir -p ${jail_root}/root$(dirname ${brand_root})
cp -r ${brand_root} ${jail_root}/root$(dirname ${brand_root})
install_brand_files ${brand_root} ${jail_root}
install_etc_resolv_conf ${jail_root}
install_authorized_keys ${jail_root}
#TODO: network config:
# * get resolvers and set them resolvers
# * routs? (do we need to set them?)
#TODO: get rood autorized keys set set them
......@@ -67,3 +67,31 @@ clean_outer_root() {
-delete
}
install_etc_resolv_conf() {
jail_root=$1
if [ -f "${jail_root}/root/config/resolvers" ]
then
for r in $(cat "${jail_root}/root/config/resolvers")
do
echo "nameserver ${r}" >> ${jail_root}/root/jail/etc/resolv.conf
done
fi
}
install_authorized_keys() {
jail_root=$1
if [ -f "${jail_root}/root/config/root_authorized_keys" ]
then
mkdir -p "${jail_root}/root/jail/root/.ssh"
cp "${jail_root}/root/config/root_authorized_keys" "${jail_root}/root/jail/root/.ssh/authorized_keys"
fi
}
expand_linked() {
for file in $1
do
echo "${file}"
ldd -a "${file}" 2> /dev/null | awk '/=>/{print $(NF-1)}'
done
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment