From: Zoltán Felleg Date: Fri, 15 Nov 2019 18:32:36 +0000 (+0100) Subject: Updated crt.sh, added logrotate timer to postinstall scripts. X-Git-Url: http://git.useribm.hu/?a=commitdiff_plain;h=0ad12246b0f4786f73c5d7a3b3dcde27a591fa31;p=user-lxc.git Updated crt.sh, added logrotate timer to postinstall scripts. --- diff --git a/scripts/crt.sh b/scripts/crt.sh index 1ed0c22..b526b39 100755 --- a/scripts/crt.sh +++ b/scripts/crt.sh @@ -9,31 +9,6 @@ then exit 1 fi -CONTAINER_NAME=$(basename $1) -CONTAINER_OS=$(echo $CONTAINER_NAME | sed 's/^.*\.\([^\.]*\)$/\1/') -CONTAINER_BASENAME=$(basename $CONTAINER_NAME .$CONTAINER_OS) -case "$CONTAINER_OS" in - "f30") - DNF_RELEASEVER=30 - PREV_CONTAINER_OS="f29" - ;; - "f29") - DNF_RELEASEVER=29 - PREV_CONTAINER_OS="f28" - ;; - *) - echo "Unknown operating system: $CONTAINER_OS" >&2 - exit 1 - ;; -esac - -SCRIPT_PATH=$(dirname $(realpath $0)) -BASE_PATH=$(dirname $SCRIPT_PATH) -BACKUPS_PATH=$BASE_PATH/backups -BUILD_PATH=$BASE_PATH/build -FILESYSTEMS_PATH=$BASE_PATH/filesystems -SOURCES_PATH=$BASE_PATH/sources - if [ -f /etc/lxc/lxc.conf ] then LXC_PATH=$(grep '^lxc.lxcpath' /etc/lxc/lxc.conf \ @@ -43,10 +18,12 @@ else exit 1 fi -CONTAINER_PATH=$LXC_PATH/$CONTAINER_NAME -CONTAINER_BUILD_PATH=$BUILD_PATH/$CONTAINER_NAME -CONTAINER_FILESYSTEMS_PATH=$FILESYSTEMS_PATH/$CONTAINER_NAME -CONTAINER_SOURCE_PATH=$SOURCES_PATH/$CONTAINER_NAME +SCRIPT_PATH=$(dirname $(realpath $0)) +BASE_PATH=$(dirname $SCRIPT_PATH) +BACKUPS_PATH=$BASE_PATH/backups +BUILD_PATH=$BASE_PATH/build +FILESYSTEMS_PATH=$BASE_PATH/filesystems +SOURCES_PATH=$BASE_PATH/sources source $SCRIPT_PATH/functions RC=$? @@ -56,16 +33,42 @@ then exit $RC fi +CONTAINER_BASENAME=$(basename $1) +CONTAINER_FILESYSTEMS_PATH=$FILESYSTEMS_PATH/$CONTAINER_BASENAME +CONTAINER_SOURCE_PATH=$SOURCES_PATH/$CONTAINER_BASENAME + ################################################################ # exit if no source exists for the container # ################################################################ if [ ! -d $CONTAINER_SOURCE_PATH ] then - echo "No source found for $CONTAINER_NAME" >&2 + echo "No source found for $CONTAINER_BASENAME" >&2 exit 1 fi source $CONTAINER_SOURCE_PATH/envvars +case "$DISTRIBUTION" in + "CentOS") + YUM_RELEASEVER=$DISTRIBUTION_VERSION + ;; + "Fedora") + DNF_RELEASEVER=$DISTRIBUTION_VERSION + ;; + *) + echo "Unknown distribution: $DISTRIBUTION" >&2 + exit 1 + ;; +esac +DISTRIBUTION_FIRST_CHAR=$(echo "$DISTRIBUTION" | cut -c 1 | tr '[A-Z]' '[a-z]') +CONTAINER_OS="${DISTRIBUTION_FIRST_CHAR}$DISTRIBUTION_VERSION" +PREV_DISTRIBUTION_VERSION=$(( $DISTRIBUTION_VERSION - 1 )) +PREV_CONTAINER_OS="${DISTRIBUTION_FIRST_CHAR}$PREV_DISTRIBUTION_VERSION" + +CONTAINER_NAME="${CONTAINER_BASENAME}.$CONTAINER_OS" + +CONTAINER_PATH=$LXC_PATH/$CONTAINER_NAME +CONTAINER_BUILD_PATH=$BUILD_PATH/$CONTAINER_NAME + ################################################################ # exit if the container build directory already exists # ################################################################ @@ -104,23 +107,62 @@ preinstall $CONTAINER_NAME \ ################################################################ # install packages into the container # ################################################################ -DNF_CONFIG=$SCRIPT_PATH/dnf.conf.fedora -dnf --assumeyes \ - --config=$DNF_CONFIG \ - --disableplugin=fastestmirror \ - --disablerepo=* \ - --enablerepo=local-* \ - --installroot=$CONTAINER_BUILD_PATH/rootfs \ - --releasever=$DNF_RELEASEVER \ - install $BASE_PACKAGES $SPEC_PACKAGES -dnf --assumeyes \ - --config=$DNF_CONFIG \ - --disableplugin=fastestmirror \ - --disablerepo=* \ - --enablerepo=local-* \ - --installroot=$CONTAINER_BUILD_PATH/rootfs \ - --releasever=$DNF_RELEASEVER \ - clean all +case "$DISTRIBUTION" in + "CentOS") + YUM_CONFIG=$SCRIPT_PATH/yum.conf.centos + yum --assumeyes \ + --config=$YUM_CONFIG \ + --disableplugin=fastestmirror \ + --disablerepo=* \ + --enablerepo=local-* \ + --installroot=$CONTAINER_BUILD_PATH/rootfs \ + --releasever=$YUM_RELEASEVER \ + install $BASE_PACKAGES + if [ -n "$SPEC_PACKAGES" ] + then + yum --assumeyes \ + --config=$YUM_CONFIG \ + --disableplugin=fastestmirror \ + --disablerepo=* \ + --enablerepo=local-* \ + --installroot=$CONTAINER_BUILD_PATH/rootfs \ + --releasever=$YUM_RELEASEVER \ + install $SPEC_PACKAGES + fi + yum --assumeyes \ + --config=$YUM_CONFIG \ + --disableplugin=fastestmirror \ + --disablerepo=* \ + --enablerepo=local-* \ + --installroot=$CONTAINER_BUILD_PATH/rootfs \ + --releasever=$YUM_RELEASEVER \ + clean all + ;; + "Fedora") + DNF_CONFIG=$SCRIPT_PATH/dnf.conf.fedora + dnf --assumeyes \ + --config=$DNF_CONFIG \ + --disablerepo=* \ + --enablerepo=local-* \ + --installroot=$CONTAINER_BUILD_PATH/rootfs \ + --releasever=$DNF_RELEASEVER \ + install $BASE_PACKAGES + dnf --assumeyes \ + --config=$DNF_CONFIG \ + --disablerepo=* \ + --enablerepo=local-* \ + --installroot=$CONTAINER_BUILD_PATH/rootfs \ + --releasever=$DNF_RELEASEVER \ + install $SPEC_PACKAGES + dnf --assumeyes \ + --config=$DNF_CONFIG \ + --disablerepo=* \ + --enablerepo=local-* \ + --installroot=$CONTAINER_BUILD_PATH/rootfs \ + --releasever=$DNF_RELEASEVER \ + clean all + ;; +esac ################################################################ # execute postinstall phase # @@ -133,14 +175,11 @@ postinstall $CONTAINER_NAME \ ################################################################ # find the old container if it exists # ################################################################ -OLD_CONTAINER_NAME= -lxc-ls --line | grep "^${CONTAINER_NAME}$" >/dev/null 2>&1 +lxc-ls -1 | grep "^${CONTAINER_NAME}$" >/dev/null 2>&1 if [ $? -eq 0 ] then OLD_CONTAINER_NAME=$CONTAINER_NAME -fi -if [ -z "$OLD_CONTAINER_NAME" ] -then +else PREV_CONTAINER_NAME="${CONTAINER_BASENAME}.$PREV_CONTAINER_OS" lxc-ls --line | grep "^${PREV_CONTAINER_NAME}$" >/dev/null 2>&1 if [ $? -eq 0 ] diff --git a/sources/efg.pm/postinstall/10_setupservices.sh b/sources/efg.pm/postinstall/10_setupservices.sh index b6097c2..7224143 100755 --- a/sources/efg.pm/postinstall/10_setupservices.sh +++ b/sources/efg.pm/postinstall/10_setupservices.sh @@ -4,4 +4,6 @@ systemctl enable NetworkManager-wait-online.service systemctl enable radvd.service +systemctl enable logrotate.timer + systemctl mask wpa_supplicant.service diff --git a/sources/ens.pm/postinstall/10_setupservices.sh b/sources/ens.pm/postinstall/10_setupservices.sh index c9bfc34..dd98b9a 100755 --- a/sources/ens.pm/postinstall/10_setupservices.sh +++ b/sources/ens.pm/postinstall/10_setupservices.sh @@ -4,4 +4,6 @@ systemctl enable named.service systemctl enable NetworkManager-wait-online.service +systemctl enable logrotate.timer + systemctl mask wpa_supplicant.service diff --git a/sources/ifg.usr/postinstall/10_setupservices.sh b/sources/ifg.usr/postinstall/10_setupservices.sh index 5250ed4..ef12a1f 100755 --- a/sources/ifg.usr/postinstall/10_setupservices.sh +++ b/sources/ifg.usr/postinstall/10_setupservices.sh @@ -1,7 +1,9 @@ #!/bin/sh -#systemctl enable iptables.service +systemctl enable radvd.service systemctl enable NetworkManager-wait-online.service +systemctl enable logrotate.timer + systemctl mask wpa_supplicant.service diff --git a/sources/ldap.usr/postinstall/10_setupservices.sh b/sources/ldap.usr/postinstall/10_setupservices.sh index e8ab8f0..239315e 100755 --- a/sources/ldap.usr/postinstall/10_setupservices.sh +++ b/sources/ldap.usr/postinstall/10_setupservices.sh @@ -6,4 +6,6 @@ systemctl enable slapd.service systemctl enable sssd.service systemctl enable NetworkManager-wait-online.service +systemctl enable logrotate.timer + systemctl mask wpa_supplicant.service diff --git a/sources/pns.pm/postinstall/10_setupservices.sh b/sources/pns.pm/postinstall/10_setupservices.sh index c9bfc34..dd98b9a 100755 --- a/sources/pns.pm/postinstall/10_setupservices.sh +++ b/sources/pns.pm/postinstall/10_setupservices.sh @@ -4,4 +4,6 @@ systemctl enable named.service systemctl enable NetworkManager-wait-online.service +systemctl enable logrotate.timer + systemctl mask wpa_supplicant.service diff --git a/sources/svc.usr/postinstall/10_setupservices.sh b/sources/svc.usr/postinstall/10_setupservices.sh index cb7f13f..00a8c87 100755 --- a/sources/svc.usr/postinstall/10_setupservices.sh +++ b/sources/svc.usr/postinstall/10_setupservices.sh @@ -6,3 +6,5 @@ systemctl disable postfix.service systemctl enable dhcpd.service systemctl enable named.service systemctl enable NetworkManager-wait-online.service + +systemctl enable logrotate.timer diff --git a/sources/ws.pm/postinstall/10_setupservices.sh b/sources/ws.pm/postinstall/10_setupservices.sh index f1593d2..e1d3ef5 100755 --- a/sources/ws.pm/postinstall/10_setupservices.sh +++ b/sources/ws.pm/postinstall/10_setupservices.sh @@ -4,4 +4,6 @@ systemctl disable httpd.service systemctl enable NetworkManager-wait-online.service +systemctl enable logrotate.timer + systemctl mask wpa_supplicant.service