changeset 219:39b736a91d0d

Begin a "configure" command for jails
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 29 Aug 2022 09:40:01 +0200
parents e370985c08ad
children 9addf133d208
files sbin/fjail
diffstat 1 files changed, 42 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/sbin/fjail	Thu Aug 25 08:54:31 2022 +0200
+++ b/sbin/fjail	Mon Aug 29 09:40:01 2022 +0200
@@ -64,6 +64,11 @@
 
     Populate the jail directory in MOUNTPOINT with the base system in BASETXZ
 
+  configure MOUNPOINT
+
+    Configure some basic parts of the system at MOUNTPOINT:
+    disable root password, syslog and other basic configuration settings
+
   copy [OPTIONS] SOURCE-DATASET DEST-DATASET
 
     Copy a tree of ZFS datasets with "zfs send -R" and "zfs receive".
@@ -319,6 +324,40 @@
 
 
 #
+# "configure" -- configure the mountpoint
+#
+# command_configure mountpoint
+#
+command_configure() {
+    # mountpoint
+    local _mp
+
+    _mp="$1"
+
+    if [ -z "${_mp}" ]; then
+        echo "ERROR: no mountpoint given" >&2
+        return 2
+    fi
+    if [ ! -d "${_mp}" ]; then
+        echo "ERROR: mountpoint \`${_mp}' does not exist" >&2
+        return 1
+    fi
+
+    # Deactive the by default empty root password
+    pw -R "${_mp}" usermod -w no -n root
+
+    sysrc -R "${_mp}" sendmail_enable=NONE
+    sysrc -R "${_mp}" clear_tmp_enable=YES
+    sysrc -R "${_mp}" clear_tmp_X=NO
+    sysrc -R "${_mp}" syslogd_flags=-ss
+    sysrc -R "${_mp}" bsdstats_enable=NO       # no automatic BSD stats when booting
+
+    # Timezone to CET
+    ln -s ../usr/share/zoneinfo/Europe/Berlin "${_mp}/etc/localtime"
+}
+
+
+#
 # "copy" -- ZFS copy of datasets
 #
 # command_copy source-dataset destination-dataset
@@ -621,6 +660,9 @@
     populate)
         command_populate "$@"
         ;;
+    configure)
+        comment_configure "$@"
+        ;;
     copy)
         command_copy "$@"
         ;;