From 8d5553a4d5b97880be0b1eddc9c826ef1e976dbe Mon Sep 17 00:00:00 2001 From: Nicolas Pierron Date: Fri, 2 Jan 2009 16:06:56 +0000 Subject: [PATCH] move some command to activate the configuration from activate-configuration.sh to system-options.nix. svn path=/nixos/branches/fix-style/; revision=13677 --- system/activate-configuration.sh | 54 ------------------------- system/system-options.nix | 69 ++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 54 deletions(-) diff --git a/system/activate-configuration.sh b/system/activate-configuration.sh index 4d2bbc319af..d71987ff9a7 100644 --- a/system/activate-configuration.sh +++ b/system/activate-configuration.sh @@ -3,60 +3,6 @@ source @newActivationScript@ -# Create the required /bin/sh symlink; otherwise lots of things -# (notably the system() function) won't work. -mkdir -m 0755 -p $mountPoint/bin -ln -sfn @bash@/bin/sh $mountPoint/bin/sh - - -# Allow the kernel to find our wrapped modprobe (which searches in the -# right location in the Nix store for kernel modules). We need this -# when the kernel (or some module) auto-loads a module. -# !!! maybe this should only happen at boot time, since we shouldn't -# use modules that don't match the running kernel. -echo @modprobe@/sbin/modprobe > /proc/sys/kernel/modprobe - - -# Various log/runtime directories. -mkdir -m 0755 -p /var/run -mkdir -m 0755 -p /var/run/console # for pam_console - -touch /var/run/utmp # must exist -chmod 644 /var/run/utmp - -mkdir -m 0755 -p /var/run/nix/current-load # for distributed builds -mkdir -m 0700 -p /var/run/nix/remote-stores - -mkdir -m 0755 -p /var/log - -touch /var/log/wtmp # must exist -chmod 644 /var/log/wtmp - -touch /var/log/lastlog -chmod 644 /var/log/lastlog - -mkdir -m 1777 -p /var/tmp - - -# Empty, read-only home directory of many system accounts. -mkdir -m 0555 -p /var/empty - - -# If there is no password file yet, create a root account with an -# empty password. -if ! test -e /etc/passwd; then - rootHome=/root - touch /etc/passwd; chmod 0644 /etc/passwd - touch /etc/group; chmod 0644 /etc/group - touch /etc/shadow; chmod 0600 /etc/shadow - # Can't use useradd, since it complains that it doesn't know us - # (bootstrap problem!). - echo "root:x:0:0:System administrator:$rootHome:@defaultShell@" >> /etc/passwd - echo "root::::::::" >> /etc/shadow - echo | passwd --stdin root -fi - - # Create system users and groups. @shell@ @createUsersGroups@ @usersList@ @groupsList@ diff --git a/system/system-options.nix b/system/system-options.nix index 0514e87dc67..ff1adfedd30 100644 --- a/system/system-options.nix +++ b/system/system-options.nix @@ -115,6 +115,75 @@ in '' [ activateLib.defaultPath # path to ln ]; + + binsh = FullDepEntry '' + # Create the required /bin/sh symlink; otherwise lots of things + # (notably the system() function) won't work. + mkdir -m 0755 -p $mountPoint/bin + ln -sfn @bash@/bin/sh $mountPoint/bin/sh + '' [ + activateLib.defaultPath # path to ln & mkdir + activateLib.stdio # ? + ]; + + modprobe = FullDepEntry '' + # Allow the kernel to find our wrapped modprobe (which searches in the + # right location in the Nix store for kernel modules). We need this + # when the kernel (or some module) auto-loads a module. + # !!! maybe this should only happen at boot time, since we shouldn't + # use modules that don't match the running kernel. + echo @modprobe@/sbin/modprobe > /proc/sys/kernel/modprobe + '' [ + # ? + ]; + + var = FullDepEntry '' + # Various log/runtime directories. + mkdir -m 0755 -p /var/run + mkdir -m 0755 -p /var/run/console # for pam_console + + touch /var/run/utmp # must exist + chmod 644 /var/run/utmp + + mkdir -m 0755 -p /var/run/nix/current-load # for distributed builds + mkdir -m 0700 -p /var/run/nix/remote-stores + + mkdir -m 0755 -p /var/log + + touch /var/log/wtmp # must exist + chmod 644 /var/log/wtmp + + touch /var/log/lastlog + chmod 644 /var/log/lastlog + + mkdir -m 1777 -p /var/tmp + + + # Empty, read-only home directory of many system accounts. + mkdir -m 0555 -p /var/empty + '' [ + activateLib.defaultPath # path to mkdir & touch & chmod + ]; + + rootPasswd = FullDepEntry '' + # If there is no password file yet, create a root account with an + # empty password. + if ! test -e /etc/passwd; then + rootHome=/root + touch /etc/passwd; chmod 0644 /etc/passwd + touch /etc/group; chmod 0644 /etc/group + touch /etc/shadow; chmod 0600 /etc/shadow + # Can't use useradd, since it complains that it doesn't know us + # (bootstrap problem!). + echo "root:x:0:0:System administrator:$rootHome:@defaultShell@" >> /etc/passwd + echo "root::::::::" >> /etc/shadow + echo | passwd --stdin root + fi + '' [ + activateLib.defaultPath # path to touch & passwd + activateLib.etc # for /etc + # ? + ]; }; }; }