liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

liminix-rebuild.sh (761B)


      1 #!/usr/bin/env bash
      2 
      3 ssh_command=${SSH_COMMAND-ssh}
      4 
      5 reboot="reboot"
      6 
      7 case "$1" in
      8     "--no-reboot")
      9 	unset reboot
     10 	shift
     11 	;;
     12     "--fast")
     13 	reboot="soft"
     14 	shift
     15 	;;
     16 esac
     17 
     18 target_host=$1
     19 shift
     20 
     21 if [ -z "$target_host" ] ; then
     22     echo Usage: liminix-rebuild \[--no-reboot\] target-host params
     23     exit 1
     24 fi
     25 
     26 if toplevel=$(nix-build "$@" -A outputs.systemConfiguration --no-out-link); then
     27     echo systemConfiguration $toplevel
     28     min-copy-closure $target_host $toplevel
     29     $ssh_command $target_host $toplevel/bin/install
     30     case "$reboot" in
     31 	reboot)
     32 	    $ssh_command $target_host "sync; source /etc/profile; reboot"
     33 	    ;;
     34 	soft)
     35 	    $ssh_command $target_host $toplevel/bin/restart-services
     36 	    ;;
     37 	*)
     38 	    ;;
     39     esac
     40 else
     41     echo Rebuild failed
     42 fi