diff options
author | Jonathan Bauer | 2013-07-31 19:05:27 +0200 |
---|---|---|
committer | Jonathan Bauer | 2013-07-31 19:05:27 +0200 |
commit | 485f67a2bbaf45ac957b5d049f8337be625885cb (patch) | |
tree | 8dba148651a89b6ff4d03d09bafa6eadf7f4d670 /server/export_target | |
parent | [pam] removed old data dir... (diff) | |
download | tm-scripts-485f67a2bbaf45ac957b5d049f8337be625885cb.tar.gz tm-scripts-485f67a2bbaf45ac957b5d049f8337be625885cb.tar.xz tm-scripts-485f67a2bbaf45ac957b5d049f8337be625885cb.zip |
[server] added new parameter for export target. Use: ./mltk server <ip> stage32 -e stage32 <config>. Added function in export_target to pack an archive with all the files found in activated modules of server/configs/<config>
Diffstat (limited to 'server/export_target')
-rwxr-xr-x | server/export_target | 54 |
1 files changed, 41 insertions, 13 deletions
diff --git a/server/export_target b/server/export_target index aa4795c5..fd4112b6 100755 --- a/server/export_target +++ b/server/export_target @@ -13,33 +13,32 @@ # stateless clients ############################################################################# -#where we are +# where we are MODE_DIR="${ROOT_DIR}/server" -#files generated by this script land in boot +# files generated by this script land in boot SERVER_BOOT_DIR="${MODE_DIR}/boot/${REMOTE_IP}" -#builds from remote server +# builds from remote server SERVER_BUILD_DIR="${MODE_DIR}/local_builds/${REMOTE_IP}" -#stage32 sqfs directory +# stage32 sqfs directory STAGE32_SQFS_DIR="${SERVER_BOOT_DIR}/stage32_sqfs/mnt" +# target directory +SERVER_CONFIGS_DIR="${MODE_DIR}/configs" + # initial checks initial_checks() { local TOOL_STR="$TOOL_STR initial_checks:" - #check for required tools - for BIN in squashfs-tools - do - if dpkg -l "${BIN}" 2&>/dev/null; then - pinfo "Installing ${BIN}..." - apt-get -y install ${BIN} - fi - done - [ ! -d "${SERVER_BOOT_DIR}" ] && mkdir -p "${SERVER_BOOT_DIR}" + + # check if SERVER_EXPORT_TARGET is valid + if [ ! -d "${SERVER_CONFIGS_DIR}/${SERVER_EXPORT_CONFIG}" ]; then + perror "Given export config not found: ${SERVER_CONFIGS_DIR}/${SERVER_EXPORT_CONFIG}" + fi } copy_kernel() { @@ -88,6 +87,34 @@ generate_addons() { generate_config() { # generate config from the target directory + local TOOL_STR="${TOOL_STR} generate_config:" + pinfo "Generating config.tgz for '$SERVER_EXPORT_CONFIG'" + + local TARGET_CONFIG="${SERVER_CONFIGS_DIR}/${SERVER_EXPORT_CONFIG}" + + # its not possible to append files to a compressed tar archiv, so start with + # a simple tar which we will gzip at the end. + + local TARGET_CONFIG_PATH="${SERVER_CONFIGS_DIR}/config.tar" + local TARGET_COMPRESSED_CONFIG_PATH="${SERVER_CONFIGS_DIR}/config.tgz" + + [ -e "$TARGET_COMPRESSED_CONFIG_PATH" ] && rm -f "$TARGET_COMPRESSED_CONFIG_PATH" + + for MODULE_CONFIG in $(ls "$TARGET_CONFIG"); do + # add files in that directory to config.tgz + cd "$TARGET_CONFIG/$MODULE_CONFIG" || perror "Could not cd to $TARGET_CONFIG/$MODULE_CONFIG" + tar rf "${TARGET_CONFIG_PATH}" $(ls) + RET=$? + if [ "x$RET" != "x0" ]; then + # something went wrong + perror "Could not add files from $MODULE_CONFIG to $TARGET_CONFIG_PATH" + fi + done + + # now gzip the tarball + gzip "${TARGET_CONFIG_PATH}" || perror "Could not gzip ${TARGET_CONFIG_PATH}" + mv "${TARGET_CONFIG_PATH}.gz" "${TARGET_COMPRESSED_CONFIG_PATH}" + } export_target() { @@ -104,6 +131,7 @@ case "$2" in ;; stage32) generate_stage32 + generate_config ;; addons) generate_addons |