diff options
author | Nicolás Reynolds <apoyosis@correo.inta.gob.ar> | 2012-07-29 19:29:13 -0300 |
---|---|---|
committer | Nicolás Reynolds <apoyosis@correo.inta.gob.ar> | 2012-07-29 19:29:13 -0300 |
commit | fb73f5847b81d93beaf85f7c35999ce01527b097 (patch) | |
tree | 2bf8c60ceb8953c2770331370c2fdedf580c5a27 /functions | |
parent | 97232dd346b6e959675def22596d034100d6e91b (diff) | |
parent | ad6100d47b2d5337d1645e946de6f450dc990ff8 (diff) |
Merge branch 'master' of git://projects.archlinux.org/initscripts
Conflicts:
Makefile
rc.conf
rc.sysinit
Diffstat (limited to 'functions')
-rw-r--r-- | functions | 81 |
1 files changed, 51 insertions, 30 deletions
@@ -171,13 +171,22 @@ stat_die() { } status() { - [[ $1 = '-v' ]] && { local v=1; shift; } + local quiet + case $1 in + -q) + quiet=1 + ;;& + -v) + # NOOP: supported for backwards compat + shift + ;; + esac stat_busy "$1" shift - if (( v )); then - "$@" - else + if (( quiet )); then "$@" &>/dev/null + else + "$@" fi local ret=$? (( ret == 0 )) && stat_done || stat_fail @@ -335,6 +344,16 @@ kill_all() { fi } +print_welcome() { + # see os-release(5) + . /etc/os-release + + echo " " + printhl "${PRETTY_NAME}\n" + printhl "${C_H2}${HOME_URL}" + printsep +} + load_modules() { local rc=0 @@ -363,7 +382,7 @@ udevd_modprobe() { stat_done # Load modules from the MODULES array and modules-load.d - status -v "Loading user-specified modules" load_modules + status "Loading user-specified modules" load_modules status "Waiting for udev uevents to be processed" \ udevadm settle @@ -386,8 +405,7 @@ do_unlock_legacy() { # $2 = source device # $3 = password # $4 = options - stat_append "${1}.." - printf "${C_FAIL}Using legacy crypttab format. This will stop working in the future. See crypttab(5).${C_OTHER}\n" + printf "${C_FAIL}Using legacy crypttab format. This will stop working in the future. See crypttab(5).${C_CLEAR}\n" local open=create a=$1 b=$2 failed=0 # Ordering of options is different if you are using LUKS vs. not. # Use ugly swizzling to deal with it. @@ -416,7 +434,7 @@ do_unlock_legacy() { if (( _overwriteokay == 0 )); then false elif cryptsetup -d /dev/urandom $4 $open "$a" "$b" >/dev/null; then - stat_append "creating swapspace.." + printf "creating swapspace..\n" mkswap -f -L $1 /dev/mapper/$1 >/dev/null fi;; ASK) @@ -451,43 +469,38 @@ do_unlock_legacy() { *) echo "$3" | cryptsetup $4 $open "$a" "$b" >/dev/null;; esac - if (( $? )); then - failed=1 - stat_append "failed " - else - stat_append "ok " - fi - return $failed + return $? } do_unlock_systemd() { - stat_append "${1}.." - local failed=0 - if ! /usr/lib/systemd/systemd-cryptsetup attach "$1" "$2" "$3" $4; then + local name=$1 device=$2 password=$3 options=$4 failed=0 + + if ! /usr/lib/systemd/systemd-cryptsetup attach "$name" "$device" "$password" $options; then failed=1 else - IFS=, + options=${options//,/ } if in_array swap ${options[@]}; then - if ! mkswap /dev/mapper/$name >/dev/null; then + # create swap on the device only if no fs signature exists + blkid -p "$2" &>/dev/null + if (( $? != 2 )) || ! mkswap -f /dev/mapper/$name >/dev/null; then failed=1 fi elif in_array tmp ${options[@]}; then - if ! mke2fs /dev/mapper/$name >/dev/null; then + # create fs on the device only if no fs signature exists + blkid -p "$2" &>/dev/null + if (( $? != 2 )) || ! mke2fs /dev/mapper/$name >/dev/null; then failed=1 fi fi fi - if (( $failed )); then - stat_append "failed " - else - stat_append "ok " - fi return $failed } do_unlock() { local name=$1 device=$2 password=$3 options=$4 + printf "${C_MAIN}Unlocking $1${C_CLEAR}\n" + if [[ ${options:0:2} =~ -. ]]; then do_unlock_legacy "$name" "$device" "$password" "$options" return $? @@ -511,9 +524,17 @@ do_unlock() { do_unlock_legacy "$name" "$device" "$password" "$options" ;; esac + failed=$? + if (( $failed )); then + printf "${C_FAIL}Unlocking of $1 failed.${C_CLEAR}\n" + fi return $? } +do_lock() { + status "Detaching encrypted device ${1}" /usr/lib/systemd/systemd-cryptsetup detach "$1" >/dev/null +} + read_crypttab() { # $1 = function to call with the split out line from the crypttab local line nspo failed=0 @@ -599,7 +620,7 @@ fsck_reboot() { } mount_all() { - mount -a -t "nosysfs,no${NETFS//,/,no}" -O no_netdev + mount -a -t "no${NETFS//,/,no}" -O no_netdev } umount_all() { @@ -634,7 +655,7 @@ umount_all() { } remove_leftover() { - status -v 'Removing leftover files' systemd-tmpfiles --create --remove --clean + status 'Removing leftover files' systemd-tmpfiles --create --remove --clean } bootlogd_stop() { @@ -702,7 +723,7 @@ if (( RC_FUNCTIONS_HOOK_FUNCS_DEFINED != 1 )); then declare -r RC_FUNCTIONS_HOOK_FUNCS_DEFINED=1 fi -if [[ $DAEMON_LOCALE = [yY][eE][sS] ]]; then +if [[ $DAEMON_LOCALE != [nN][oO] ]]; then export LANG=${LOCALE:-C} if [[ -r /etc/locale.conf ]]; then parse_envfile /etc/locale.conf "${localevars[@]}" @@ -712,7 +733,7 @@ else fi # set colors -if [[ $USECOLOR = [yY][eE][sS] ]]; then +if [[ $USECOLOR != [nN][oO] ]]; then if tput setaf 0 &>/dev/null; then C_CLEAR=$(tput sgr0) # clear text C_MAIN=${C_CLEAR}$(tput bold) # main text |