blob: 587804d981e36c8b6157abe5be6801e09ca454b1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
#!/bin/bash
# Copyright (c) 2012 - OpenSLX GmbH
#
# This program is free software distributed under the GPL version 2.
# See http://openslx.org/COPYING
#
# If you have any feedback please consult http://openslx.org/feedback and
# send your feedback to feedback@openslx.org
#
# General information about OpenSLX can be found at http://openslx.org
#
# Server side script to generate stage3.1,2 initial ramfses for OpenSLX Linux
# stateless clients
#############################################################################
#where we are
MODE_DIR="${ROOT_DIR}/server"
#files generated by this script land in boot
SERVER_BOOT_DIR="${MODE_DIR}/boot"
#builds from remote server
SERVER_BUILD_DIR="${MODE_DIR}/remote_builds"
REMOTE_BUILD_DIR="${ROOT_DIR}/remote/builds"
#stage32 sqfs directory
STAGE32_SQFS_DIR="${SERVER_BOOT_DIR}/stage32_sqfs/mnt"
# initial checks
initial_checks() {
local TOOL_STR="$TOOL_STR initial_checks:"
#check for required tools
for BIN in mksquashfs
do
local TEST=$(which ${BIN})
[ -z "${TEST}" ] && pinfo "Installing ${BIN}..." && apt-get install ${BIN}
done
[ ! -d "${SERVER_BOOT_DIR}" ] && mkdir -p "${SERVER_BOOT_DIR}"
}
sync_remote() {
pinfo "Synching 'remote/builds' to 'server/remote_builds'..."
#TODO setup link to remote build directory, later this directory will be rsynced or exported to this server...
if [ ! -d "${SERVER_BUILD_DIR}" ]; then
[ ! -d "${REMOTE_BUILD_DIR}" ] && perror "remote 'builds' directory not found, exiting."
ln -s "${REMOTE_BUILD_DIR}" "${SERVER_BUILD_DIR}"
fi
}
generate_stage32() {
local TOOL_STR="${TOOL_STR} generate_stage32:"
[ ! -d "${STAGE32_SQFS_DIR}" ] && mkdir -p "${STAGE32_SQFS_DIR}"
[ -e "${STAGE32_SQFS_DIR}/${TARGET}.sqfs" ] && rm "${STAGE32_SQFS_DIR}/${TARGET}.sqfs"
pinfo "Writing '${TARGET}.sqfs' to '${STAGE32_SQFS_DIR}/${TARGET}.sqfs'"
mksquashfs "${SERVER_BUILD_DIR}/${TARGET}" "${STAGE32_SQFS_DIR}/${TARGET}.sqfs" -comp xz -b 1M -no-recovery >&6 || perror "mksquashfs failed ($?)."
generate_initramfs "${SERVER_BOOT_DIR}/stage32_sqfs" "./mnt/${TARGET}.sqfs" "${SERVER_BOOT_DIR}/initramfs-${TARGET}"
}
generate_stage31() {
local TOOL_STR="${TOOL_STR} generate_stage31:"
pinfo "Writing 'initramfs-${TARGET}' to '${SERVER_BOOT_DIR}'"
generate_initramfs "${SERVER_BUILD_DIR}/${TARGET}" "." "${SERVER_BOOT_DIR}/initramfs-${TARGET}"
}
generate_addons() {
local TOOL_STR="${TOOL_STR} generate_addons:"
pinfo "Writing '${TARGET}.sqfs' to '${SERVER_BOOT_DIR}/${TARGET}.sqfs'"
[ -e "${SERVER_BOOT_DIR}/${TARGET}.sqfs" ] && rm "${SERVER_BOOT_DIR}/${TARGET}.sqfs"
mksquashfs "${SERVER_BUILD_DIR}/${TARGET}" "${SERVER_BOOT_DIR}/${TARGET}.sqfs" -comp xz -b 1M -no-recovery >&6 || perror "mksquashfs failed ($?)."
}
export_target() {
initial_checks
TARGET=$1
[ -d ${SERVER_BUILD_DIR}/${TARGET} ] || perror "Given target directory does not exist: ${SERVER_BUILD_DIR}/${TARGET}"
case "$2" in
stage31)
generate_stage31
;;
stage32)
generate_stage32
;;
addons)
generate_addons
;;
esac
}
clean_target() {
TARGET=$1
local TOOL_STR="$TOOL_STR clean_target"
pinfo "Cleaning '${SERVER_BUILD_DIR}/${TARGET}'..."
[ -d "${SERVER_BUILD_DIR}/${TARGET}" ] && { rm -rf "${SERVER_BUILD_DIR}/${TARGET}" || perror "rm -rf failed."; }
pinfo "Cleaning '${SERVER_BOOT_DIR}/kernel'..."
[ -e "${SERVER_BOOT_DIR}/kernel" ] && { rm "${SERVER_BOOT_DIR}/kernel" || perror "rm failed."; }
pinfo "Cleaning '${SERVER_BOOT_DIR}/initramfs-${TARGET}'..."
[ -e "${SERVER_BOOT_DIR}/initramfs-${TARGET}" ] && { rm "${SERVER_BOOT_DIR}/initramfs-${TARGET}" || perror "rm failed."; }
pinfo "Cleaning '${SERVER_BOOT_DIR}/${TARGET}.sqfs'..."
[ -e "${SERVER_BOOT_DIR}/${TARGET}.sqfs" ] && { rm "${SERVER_BOOT_DIR}/${TARGET}.sqfs" || perror "rm failed."; }
pinfo "Cleaning '${SERVER_BOOT_DIR}/stage32_dqfs/mnt/${TARGET}.sqfs'..."
[ -e "${SERVER_BOOT_DIR}/stage32_sqfs/mnt/${TARGET}.sqfs" ] && { rm "${SERVER_BOOT_DIR}/stage32_sqfs/mnt/${TARGET}.sqfs" || perror "rm failed."; }
}
|