From 6a1f59bfeeb95ec181b36ce0236e0a9cd6baa691 Mon Sep 17 00:00:00 2001 From: Alexandros Kiousis Date: Wed, 17 Sep 2014 20:25:03 +0300 Subject: [PATCH 1/2] Add a SELINUX relabel function for RHEL-like oses --- common.sh.in | 19 +++++++++++++++++++ create | 2 ++ 2 files changed, 21 insertions(+) diff --git a/common.sh.in b/common.sh.in index 804d049..7083848 100644 --- a/common.sh.in +++ b/common.sh.in @@ -399,6 +399,25 @@ setup_console() { esac } +filesystem_check() { + local target=$1 + if [ -z "$target" ] ; then + log_error "target not set for filesystem_check" + exit 1 + fi + + get_os $target + + case "${OPERATING_SYSTEM}" in + fedora|centos|redhat) + # we have to force a filesystem relabeling for SELinux after messing + # around with the filesystem in fedora + echo "Enforce an automatic relabeling in the initial boot process..." + touch $target/.autorelabel + ;; + esac +} + cleanup() { if [ ${#CLEANUP[*]} -gt 0 ]; then LAST_ELEMENT=$((${#CLEANUP[*]}-1)) diff --git a/create b/create index a6c7f64..e9eaad9 100755 --- a/create +++ b/create @@ -119,6 +119,8 @@ if [ "$CDINSTALL" = "no" ] ; then setup_console $TARGET fi + filesystem_check $TARGET + RUN_PARTS=`which run-parts` if [ -n "$RUN_PARTS" -a -n "$CUSTOMIZE_DIR" -a -d "$CUSTOMIZE_DIR" ]; then From 60f598b4c94d3545d28e7e535b2947645915eb14 Mon Sep 17 00:00:00 2001 From: Alexandros Kiousis Date: Thu, 18 Sep 2014 15:01:53 +0300 Subject: [PATCH 2/2] A hook that randomizes the system crontab --- example/hooks/cron_randomize | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 example/hooks/cron_randomize diff --git a/example/hooks/cron_randomize b/example/hooks/cron_randomize new file mode 100644 index 0000000..25f02a5 --- /dev/null +++ b/example/hooks/cron_randomize @@ -0,0 +1,28 @@ +#!/bin/bash + +# +# Copyright (C) 2011 Greek Research and Technology Network +# + +set -e + +. common.sh + +debug set -x + +trap cleanup EXIT + +n=$RANDOM +min=$(( n %= 30 )) + +echo "SHELL=/bin/sh" > ${TARGET}/etc/crontab +echo "PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" >> ${TARGET}/etc/crontab +printf "\n" >> ${TARGET}/etc/crontab +echo "# m h dom mon dow user command" >> ${TARGET}/etc/crontab +echo "$min * * * * root cd / && run-parts --report cron.hourly" >> ${TARGET}/etc/crontab +echo "$((min + 7)) 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report cron.daily )" >> ${TARGET}/etc/crontab +echo "$((min + 13)) 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report cron.weekly )" >> ${TARGET}/etc/crontab +echo "$((min + 24)) 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report cron.monthly )" >> ${TARGET}/etc/crontab + +trap - EXIT +exit 0