Patch title: Release 89 bulk changes
Abstract:
File: /fullpliant/computer.page
Key:
    Removed line
    Added line
module "/pliant/language/context.pli"
module "rules.pli"
module "install.pli"
module "embedded/install.pli"
module "embedded/compile.pli"
module "computer.pli"
module "debian.pli"

module "/pliant/admin/file.pli"
module "/pliant/admin/execute.pli"
module "/pliant/protocol/dns/name.pli"
module "/pliant/linux/storage/cdrom.pli"
module "/pliant/linux/storage/partition.pli"
module "/pliant/linux/storage/filesystem.pli"
module "/pliant/linux/storage/raid.pli"

module "/pliant/language/stream.pli"
module "/pliant/appli/forum/difference.pli"

requires "browse_configuration"


title "Computers administration"

para
  link "defining computer components (for experts only)" "/pliant/fullpliant/component"

[List of currently defined computers:]

table columns 2
  cell header
    [Computer name]
  cell
    void
  each c computer
    cell
      fixed (text keyof:c)
    cell
      page button "Edit"
        read_only not allowed:"administrator"
        title "Computer '"+keyof:c+"'"

        header "'"+keyof:c+"' definition"
       
          table columns 4
            cell header
              [Line ID]
            cell header
              [Component]
            cell header
              [Instance]
            cell header
              [Extra parameters]
            each cc c:content
              cell
                fixed (text keyof:cc)
              cell
                input "" cc:component length 25
              cell
                input "" cc:instance length 8
              cell
                if not (exists computer_database:data:component:(cc component))
                  highlight "not defined"
                display_variables c cc:component cc:instance
      
          if allowed:"administrator"
            input "Line ID: " (var Str ccid) noeol
            button "Add a line" noeol
              c:content create ccid
              reload_page
            button "Remove the line"
              c:content delete ccid
              reload_page

          button "Update, then back to computers list"
            goto_backward

        header "Prepare '"+keyof:c+"'"

          button "Upgrade Debian packages list" noeol
            if allowed:"administrator"
              [Are you sure that you want to download load new lists of Packages ? ]
              button "yes" noeol
                if debian_upgrade:c=success
                  goto_backward
                else
                  [Failed to download the new Packages list.]
              button "no"
                goto_backward
            else
              [Only the administrator can do that !]
          button "Check for software updates" noeol
            if allowed:"administrator"
              each sw c:env:"software"
                console "check " keyof:sw
                var Str v := sw "version"
                if ((v (v search_last "." -1)+1 v:len) parse (var Int index)) and (sw:"download" search "*" -1)<>(-1)
                  var Str ok := v
                  part try_next_release
                    index += 1
                    v := (v 0 (v search_last "." -1)+1)+string:index
                    var Str url := replace sw:"download" "*" v
                    (var Stream test) open url in+safe
                    if test=success
                      console " yes"
                      ok := v
                      restart try_next_release
                  console eol
                  if ok<>sw:"version"
                    text keyof:sw+" can be upgraded from "+sw:"version"+" to "+ok ; eol
            else
              [Only the administrator can do that !]
          button "Download packages"
            if allowed:"administrator"
              var Status status := success
              if (debian_download c false)=failure
                [Failed to download some packages.]
                status := failure
              if embedded_download:c=failure
                [Failed to download some applications.]
                status := failure
              if status=success
                reload_page
            else
              [Only the administrator can do that !]
          button "Reset and compute settings" noeol
            if allowed:"administrator"
              [Are you sure that you want to reset settings ? ]
              button "yes" noeol
                c compute true "file:/tmp/rules.log"
                goto_backward
              button "no"
                goto_backward
              [It's generally no problem to reset settings, but if you had forced some settings in the computer definition input fields, then you will have to redo since the default values will be restored.]
            else
              [Only the administrator can do that !]
          button "Recompute settings"
            if allowed:"administrator"
              var ExtendedStatus status := c compute false "file:/tmp/rules.log"
              if status=success
                reload_page
              else
                [Failed to compute computer settings:] ; eol
                fixed (text status:message)
            else
              [Only the administrator can do that !]

          button "Display settings" noeol
            title "Computer '"+keyof:c+"' settings"
            each category c:env
              header keyof:category
                each instance category
                  para
                    bold (text keyof:instance) ; eol
                  each id instance
                    italic (text keyof:id+":") ; fixed (text "  "+id) ; eol
          button "Smart display kernel settings" noeol
            display_kernel_settings c
          button "Display raw settings database"
            var Str temp := file_temporary
            var (Link Database:Computer) target_database :> new Database:Computer
            target_database load temp
            data_copy c target_database:data
            target_database store
            data_store
            reset_http_answer
            http_request send_static_file temp "mime [dq]text/plain[dq]"       
            file_delete temp
  
        var Str name := keyof c ; name := name 0 (name search "." name:len)

        header "Build an install medium for '"+keyof:c+"'"

          if c:env:"pliant":"system":"medium"="cdrom"

            page button "Engrave a recovery CD" 
              if c:env:"partition":"root":"device"=""
                [You cannot engrave the CD without a root partition defined, specifying the CD device.]
              eif allowed:"administrator"
                title "Engrave a recovery CD"
                table columns 4 border 0
                  cell
                    highlight "warning:"
                  cell
                    [Selecting yes will eraze your] ; eol
                  cell
                    fixed [file:/usr/src/linux/] ; eol
                    fixed [file:/usr/src/pcmcia-cs/] ; eol
                    fixed [file:/mnt/target/] ; eol
                  cell
                    [directories.]
                input "Name of the computers you want to recover from the CD: " (var Str target_names) length 40
                select "Kind of CD: " (var Str rw)
                  option "Write only" ""
                  option "Read write" " rw"
                  option "store image to embedded:/tmp/recover.cd" "store"
                [Do you really want to engrave the CD ? ]
                page button "yes" noeol
                  part engrave_cd
                    var Str all := target_names
                    while all<>""
                      if not (all parse any:(var Str first) _ any:(var Str remain))
                        first := all ; remain := ""
                      if (file_query "file:/fullpliant/archive/"+first+".tgz" standard)=failure
                        if not (exists computer:first)
                          text "There is no '"+first+"' in the database !"
                        else
                          text "The target system archive for '"+first+"' is not built yet !"
                        leave engrave_cd
                      all := remain
                    var ExtendedStatus status := install_tree c "file:/mnt/target/" "generate_site_key"
                    if status=success
                      var Str all := target_names
                      while all<>""
                        if not (all parse any:(var Str first) _ any:(var Str remain))
                          first := all ; remain := ""
                        file_copy "file:/fullpliant/archive/"+first+".tgz" "file:/mnt/target/fullpliant/archive/"+first+".tgz"
                        var Str embedded := computer:first:env:"pliant":"system":"embedded"
                        if embedded<>""
                          file_copy "file:/fullpliant/archive/embedded/"+embedded+".tgz" "file:/mnt/target/fullpliant/archive/embedded/"+embedded+".tgz" extended+lazy
                        all := remain
                      console "Building CD the embedded boot floppy" eol
                      install_floppy c "file:/mnt/target/boot/floppy" c:env:"partition":"root":"device" ""
                      if rw="store"
                        console "storing CD image" eol
                        status := cdrom_image (var List:FileInfo empty_list) "path [dq]file:/mnt/target/[dq] boot [dq]boot/floppy[dq]" "embedded:/tmp/recover.cd"
                      else
                        console "Engraving the CD" eol
                        status := cdrom_engrave "file:/mnt/target/" "boot [dq]boot/floppy[dq]"+rw+" indirect"
                      file_tree_delete "file:/mnt/target/"
                      console "done." eol
                      if status=success
                        goto_backward
                      else
                        text "failed: "+status:message
                    else
                      console "failed." eol
                      [Failed to engrave the bootable CD for ] ; text keyof:c ; eol
                      [Error message is: ] ; eol
                      fixed (text status:message)
                button "no"
                  goto_backward
              else
                [Only the administrator can do that !]

          if c:env:"pliant":"system":"medium"="usb"

            page button "Build the bootable USB key"
            page button "Build the bootable USB key" noeol
              if allowed:"administrator"
                title "Build a bootable USB key"
                table columns 1 border 0
                  cell color (color hsl 0 50 75)
                    [This will eraze all your datas on /dev/sda disk, so you should absolutely not do that if you have any SCSI disk in your system.]
                table columns 4 border 0
                  cell
                    highlight "warning:"
                  cell
                    [Selecting yes will eraze your] ; eol
                  cell
                    fixed [embedded:/usr/src/linux/] ; eol
                    fixed [embedded:/usr/src/pcmcia-cs/] ; eol
                    fixed (text "embedded:/export/diskless/"+name+"/") ; eol
                  cell
                    [directories.]
                if (file_query "file:/fullpliant/archive/"+keyof:c+".tgz" standard)=success or (c:env:"pliant":"http":"site_key_bits" parse (var Int bits))
                  var Str key := shunt (file_query "file:/fullpliant/archive/"+keyof:c+".tgz" standard)=success "keep_site_key" "generate_site_key"
                  select "What about the site key ? " (var Str key)
                    option "do nothing" ""
                    if key="keep_site_key"
                      option "keep existing one" "keep_site_key"
                    option "generate a new one" "generate_site_key"
                var Str format := "yes"
                select "Do you want to format USB key: " (var Str format)
                  option "yes" "yes"
                  option "no" "no"
                [Do you really want to build the USB key]
                page button "yes" noeol
                  execute "insmod scsi_mod"
                  execute "insmod sd_mod"
                  execute "insmod uscore"
                  execute "insmod usb-uhci"
                  execute "insmod usb-ohci"
                  execute "insmod usb-storage"
                  sleep 1
                  partition_format "device:/sda" "ext2" ""
                  if format="yes"
                    partition_format "device:/sda" "ext2" ""
                  var ExtendedStatus status := filesystem_mount "device:/sda" "file:/mnt/target/" ""
                  if status=success
                    status := install_tree c "file:/mnt/target/" ""
                    status := install_tree c "file:/mnt/target/" key
                    if status=success
                      update_rights c "file:/mnt/target/"
                      status := lilo_install c "file:/mnt/target/" "device:/sda" "device:/sda" "" ""
                      status := lilo_install c "file:/mnt/target/" "device:/sda" "device:/sda" c:env:"kernel":"constant":"options" ""
                    filesystem_dismount "file:/mnt/target/"
                  if status=success
                    goto_backward
                  else
                    [Failed to record USB key] ; eol
                    [Error message is: ] ; eol
                    fixed (text status:message)
                button "no"
                  goto_backward
              else
                [Only the administrator can do that !]
            button "and the boot floppy"
              if allowed:"administrator"
                title "Build the boot floppy for '"+keyof:c+"'"
                para
                  [Please insert a floppy in this computer drive, then clic on the button.] ; eol
                para
                  highlight "warning: " ; [The floppy content will be erased.] ; eol
                button "Build the floppy"
                  var ExtendedStatus status := install_floppy c "device:/fd0" "device:/sda" ""
                  if status=success
                    goto_backward
                  else
                    [Failed to build the boot floppy for ] ; text keyof:c
                    para
                      fixed (text status:message)
              else
                [Only the administrator can do that !]

          if c:env:"pliant":"system":"medium"="nfs"

            button "Build the tree for installing through NFS" noeol
              if allowed:"administrator"
                title "Build the tree for installing '"+name+"' through NFS"
                table columns 4 border 0
                  cell
                    highlight "warning:"
                  cell
                    [Selecting yes will eraze your] ; eol
                  cell
                    fixed [embedded:/usr/src/linux/] ; eol
                    fixed [embedded:/usr/src/pcmcia-cs/] ; eol
                    fixed (text "embedded:/export/diskless/"+name+"/") ; eol
                  cell
                    [directories.]
                input "Name of the computer you want to install through NFS root: " (var Str target_name)
                [Do you really want to build the] ; fixed (text " embedded:/export/diskless/"+name+"/ ") ; [tree ? ]
                button "yes" noeol
                  var ExtendedStatus status := install_tree c "embedded:/export/diskless/"+name+"/" ""
                  if status=success
                    if target_name<>""
                      file_copy "file:/fullpliant/archive/"+target_name+".tgz" "embedded:/export/diskless/"+name+"/fullpliant/archive/"+target_name+".tgz"
                      var Str embedded := computer:target_name:env:"pliant":"system":"embedded"
                      if embedded<>""
                        file_copy "file:/fullpliant/archive/embedded/"+embedded+".tgz" "embedded:/export/diskless/"+name+"/fullpliant/archive/embedded/"+embedded+".tgz"
                    goto_backward
                  else
                    [Failed to build the NFS root tree for ] ; text keyof:c ; eol
                    [Error message is: ] ; eol
                    fixed (text status:message)
                button "no"
                  goto_backward
              else
                [Only the administrator can do that !]
  
            button "and the boot floppy"
              if allowed:"administrator"
                title "Build the boot floppy for '"+keyof:c+"'"
                var Str client_ip := name_ip keyof:c
                input "IP address of the target computer: " client_ip
                var Str server_ip := name_ip computer_fullname
                input "IP address of the NFS server: " server_ip
                var Str net_mask := name_mask keyof:c
                input "Net mask: " net_mask
                para
                  [Please insert a floppy in this computer drive, then clic on the button.] ; eol
                para
                  highlight "warning: " ; [The floppy content will be erased.] ; eol
                button "Build the floppy"
                  var Str options := "rw nfsroot=/export/diskless/"+name
                  options += " ip="+client_ip+":"+server_ip+"::"+net_mask+":"+name+":eth0"
                  var ExtendedStatus status := install_floppy c "device:/fd0" "device:/nfs" options
                  if status=success
                    goto_backward
                  else
                    [Failed to build the boot floppy for ] ; text keyof:c
                    para
                      fixed (text status:message)
              else
                [Only the administrator can do that !]
  
          button "Build the target system archive" noeol
            if allowed:"administrator"
              var Str distrib := c:env:"pliant":"system":"distribution"
              title "Build file:/fullpliant/archive/"+keyof:c+".tgz"
              table columns 4 border 0
                cell
                  highlight "warning:"
                cell
                  [Selecting yes will eraze your] ; eol
                cell
                  fixed [file:/usr/src/linux/] ; eol
                  fixed [file:/usr/src/pcmcia-cs/] ; eol
                  fixed [file:/mnt/target/] ; eol
                cell
                  [directories.]
              if (file_query "file:/fullpliant/archive/"+keyof:c+".tgz" standard)=success or (c:env:"pliant":"http":"site_key_bits" parse (var Int bits))
                var Str key := shunt (file_query "file:/fullpliant/archive/"+keyof:c+".tgz" standard)=success "keep_site_key" ""
                select "What about the site key ? " (var Str key)
                  option "do nothing" ""
                  if key="keep_site_key"
                    option "keep existing one" "keep_site_key"
                  option "generate a new one" "generate_site_key"
              var Str embedded := c:env:"pliant":"system":"embedded"
              var Str keep_emb := shunt embedded<>"" and (file_query "file:/fullpliant/archive/embedded/"+embedded+".tgz" standard)=success "yes" "no"
              if keep_emb="yes"
                select "Do you want to keep the old embedded computer ? " keep_emb
                  option "yes" "yes"
                  option "no" "no"
              [Do you really want to build the system archive in] ; fixed [ file:/fullpliant/archive/ ] ; [? ]
              button "yes" noeol
                var ExtendedStatus status := install_tree c "file:/mnt/target/" key
                if status=success
                  file_tree_create "file:/fullpliant/archive/"
                  execute "tar -zc -f "+(file_os_name "file:/fullpliant/archive/"+keyof:c+".tgz")+" ." path "file:/mnt/target/"
                  file_tree_delete "file:/mnt/target/"
                  if embedded<>""
                    if keep_emb<>"yes" or (file_query "file:/fullpliant/archive/embedded/"+embedded+".tgz" standard)=undefined
                      console "Building the embedded system." eol
                      embedded_install c "file:/mnt/target/"
                      file_tree_create "file:/fullpliant/archive/embedded/"
                      console "Recording the embedded system archive." eol
                      execute "tar -zc -f "+(file_os_name "file:/fullpliant/archive/embedded/"+embedded+".tgz")+" ." path "file:/mnt/target/"
                      file_tree_delete "file:/mnt/target/"
                  goto_backward
                else
                  [Failed to build the target system archive for ] ; text keyof:c ; eol
                  [Error message is:] ; eol
                  fixed (text status:message)
              button "no"
                goto_backward
            else
              [Only the administrator can do that !]

          button "Removed all precompiled computers"
            if allowed:"administrator"
              table columns 4 border 0
                cell
                  highlight "warning:"
                cell
                  [Selecting yes will eraze your] ; eol
                cell
                  fixed [embedded:/usr/src/linux/] ; eol
                  fixed [embedded:/export/diskless/] ; eol
                  fixed [embedded:/mnt/target/] ; eol
                  fixed [file:/fullpliant/archive/] ; eol
                  fixed [file:/fullpliant/kernel/bin/] ; eol
                  fixed [file:/fullpliant/unix/bin/] ; eol
                cell
                  [directories.]
              [Are you sure that you want to remove all precompiled computers ? ]
              button "yes" noeol
                file_tree_delete "embedded:/usr/src/linux/"
                file_tree_delete "embedded:/export/diskless/"
                file_tree_delete "embedded:/mnt/target/"
                file_tree_delete "file:/fullpliant/archive/"
                file_tree_delete "file:/fullpliant/kernel/bin/"
                file_tree_delete "file:/fullpliant/unix/bin/"
                goto_backward
              button "no"
                goto_backward
            else
              [Only the administrator can do that !]

          if allowed:"administrator" and c:env:"pliant":"system":"embedded"<>""
            button "Manually compile embedded applications"
              title "Embedded applications"
              para
                [All emmbedded applications should be compiled automatically. ]
                [This page is provided so that, in case of trouble, you can manually compile one without all others, and it is usefull only because since most applications are C and C++, compiling is very long.]
              var CBool unpacked := (file_list "embedded:/mnt/target/" standard+directories):size<>0
              para
                if unpacked
                  button "Reunpack embedded computer"
                    var Str embedded := c:env:"pliant":"system":"embedded"
                    title "Reunpacking embedded computer"
                    table columns 4 border 0
                      cell
                        highlight "warning:"
                      cell
                        [Selecting yes will eraze your] ; eol
                      cell
                        fixed [embedded:/mnt/target/] ; eol
                      cell
                        [directories.]
                    [Are you sure that you want to reunpack the embedded computer ? ]
                    button "yes" noeol
                      file_tree_delete "embedded:/mnt/target/"
                      file_extract "file:/fullpliant/archive/embedded/"+embedded+".tgz" "embedded:/mnt/target/"
                      goto_backward
                    button "no"
                      goto_backward
                  button "Repack embedded computer"
                    var Str embedded := c:env:"pliant":"system":"embedded"
                    title "Repacking embedded computer"
                    para
                      [Repacking the embedded compter will replace the packed embedded computer in]
                      fixed (text " file:/fullpliant/archive/embedded/"+embedded+".tgz ")
                      [with the tree in] ; fixed [ embedded:/mnt/target/] ; eol
                    [Are you sure that you want to repack the embedded computer ? ]
                    button "yes" noeol
                      file_tree_delete "embedded:/mnt/target/usr/src/"
                      file_tree_create "embedded:/mnt/target/usr/src/"
                      execute "tar -zc -f "+(file_os_name "file:/fullpliant/archive/embedded/"+embedded+".tgz")+" ." path "embedded:/mnt/target/"
                      file_tree_delete "embedded:/mnt/target/"
                      goto_backward
                    button "no"
                      goto_backward
                else
                  highlight "warning: " ; [Embedded computer is currently not unpacked, so you cannot try to compile applications.] ; eol
                  button "Unpack embedded computer"
                    var Str embedded := c:env:"pliant":"system":"embedded"
                    file_extract "file:/fullpliant/archive/embedded/"+embedded+".tgz" "embedded:/mnt/target/"
                    reload_page
              table columns 3     
                cell header [Application]
                cell header [Status]
                cell void
                var Int done := 0 ; var Int total := 0
                each sw c:env:"software"
                  cell (text keyof:sw)
                  cell (text sw:"status")
                  cell
                    if unpacked
                      button "compile"
                        embedded_force_compile c keyof:sw "embedded:/mnt/target/"
                        reload_page
                  if sw:"status"="success"
                    done += 1
                  total += 1
              para
                text string:done+"/"+string:total+" already compiled packages[lf]"
                if unpacked and done<total
                  button (shunt total-done>1 "try to compile the "+(string total-done)+" remaining packages" "try to compile the single remaining package")
                    embedded_force_compile c "" "embedded:/mnt/target/"
                    reload_page
              para
                [Last compile report:] ; eol
                (var Stream log) open "file:/tmp/compile.log" in+safe
                fixed
                  while not log:atend
                    text log:readline ; eol
              para
                link "more detailed report" "/pliant/browse/system_file/tmp/compile2.log" options "view"

          var Str kernel_file := "file:/fullpliant/kernel/bin/kernel-"+c:env:"kernel":"constant":"linux_version"+"-"+c:env:"kernel":"constant":"signature"+".tgz"
          if allowed:"administrator"
            if (file_query kernel_file standard)=defined
              link "kernel.tgz" "computer/"+keyof:c+"/kernel.tgz" ; fixed [ ]
            if (file_query "file:/fullpliant/archive/"+keyof:c+".tgz" standard)=defined
              link "fullpliant.tgz" "computer/"+keyof:c+"/fullpliant.tgz" ; fixed [ ]
            if c:env:"pliant":"system":"embedded"<>"" and (file_query "file:/fullpliant/archive/embedded/"+c:env:"pliant":"system":"embedded"+".tgz" standard)=defined
              link c:env:"pliant":"system":"embedded"+".tgz" "computer/"+keyof:c+"/"+c:env:"pliant":"system":"embedded"+".tgz" ; fixed [ ]
            link keyof:c "http://"+keyof:c+"/pliant/browse/system_file/boot/"

        header "Install '"+keyof:c+"'"

          if (file_query "file:/proc/mdstat" standard)=success
            button "Stop RAID" noeol
              if allowed:"administrator"
                var CBool noraidtab := (file_query "file:/etc/raidtab" standard)=failure
                if noraidtab
                  (var Stream raidtab) open "file:/etc/raidtab" out+mkdir+safe
                  raidtab close
                for (var Int i) 0 15
                  execute "raidstop /dev/md"+string:i quiet
                if noraidtab
                  file_delete "file:/etc/raidtab"
                  file_delete "file:/etc/"
                reload_page
              else
                [Only the administrator can do that !]

          enumerate_partitions c (var Dictionary partitions) (var Dictionary disks)
          each d disks type Str
            var Str disk := d
            button "Partition "+disk+" disk" noeol
              if allowed:"administrator"
                title "Partitioning "+disk
                table columns 1 border 0
                  cell color (color hsl 0 50 75)
                    [This will eraze all your datas on disk] ; fixed (text " "+disk)
                [Are you sure you want to do that ? ]
                button "yes" noeol
                  install_partition c disk
                  goto_backward
                button "no"
                  goto_backward
              else
                [Only the administrator can do that !]
          eol
          each p partitions type DiskPartition
            var Str partition := p name
            var Str device := p device
            var Str devices := p raid_devices
            if partition<>"" and p:filesystem<>"raid"
              button "Format "+partition+" partition" noeol
                if allowed:"administrator"
                  title "Formating "+partition+" partition"
                  table columns 1 border 0
                    cell color (color hsl 0 50 75)
                      [This will eraze all your datas on the] ; fixed (text " "+device+" ") ; [ partition]
                      if devices<>""
                        eol ; [and also on the] ; fixed (text " "+devices+" ") ; [partitions.]
                  [Are you sure you want to do that ? ]
                  button "yes" noeol
                    install_format c partition
                    goto_backward
                  button "no"
                    goto_backward
                else
                  [Only the administrator can do that !]
          eol
          button "Install the system"
            if allowed:"administrator"
              var Str root := c:env:"partition":"root":"device"
              var Str distrib := c:env:"pliant":"system":"distribution"
              if (file_query "file:/fullpliant/archive/"+keyof:c+".tgz" standard)=defined
                title "Installing the system"
                para
                  [You are going to copy the ] ; text distrib ; [ system on ] ; fixed (text " "+root+" ") ; [partition.]
                var Str embedded := c:env:"pliant":"system":"embedded"
                if embedded<>""
                  select "Do you want to install the embedded computer also: " embedded
                    option "yes" embedded
                    option "no" ""                  
                [Do you really want to do it now ? ]
                button "yes" noeol
                  if (filesystem_mount root "file:/mnt/target/" "")=success
                    var Status status := success
                    if embedded<>""
                      if (file_extract "file:/fullpliant/archive/embedded/"+embedded+".tgz" "file:/mnt/target/"+embedded+"/")=failure
                        status := failure
                    if (file_extract "file:/fullpliant/archive/"+keyof:c+".tgz" "file:/mnt/target/")=failure
                      status := failure
                    filesystem_dismount "file:/mnt/target/"
                    if status=success
                      goto_backward
                    else
                      [Failed to extract some files.]
                  else
                    text "Failed to mount "+root+" partition."
                button "no"
                  goto_backward
              else
                [The image of the system is not available in file:/fullpliant/archive/]
            else
              [Only the administrator can do that !]

          button "Make the new system bootable"
            if allowed:"administrator"
              var Str root := c:env:"partition":"root":"device"
              title "Make "+root+" partition bootable"
              para
                var Str gbd := "hd0"
                input "GRUB boot drive: " gbd
                var Str gbp := "hd0,0"
                input "GRUB boot partition: " gbp
              para
                var Str lbd := "device:/hda"
                if (root parse "device:/sd" any)
                  lbd := "device:/sda"
                input "Lilo boot drive: " lbd
                var Str geometry := ""
                var Str geometry := "lba32"
                select "Lilo drive access mode: " geometry
                  option "auto select" ""
                  option "32 bits linear" "lba32"
                  option "24 bits linear" "linear"
                  option "old bios mode" "chs"
              var Str options := c:env:"kernel":"constant":"options"
              input "Extra Linux kernel options: " options
              table columns 2 border 0
                cell (highlight "warning:")
                cell [If you had a working operating system somewhere else on the disk or on another disk, it will not be possible to boot it anymore.]
              para
                [You are going to set the disk boot sector so that it will start the system on ] ; fixed (text " "+root+" ") ; [partition.]
              [Now install: ]
              button "GRUB" noeol
                var Str grub_options := ""
                if this_computer:env:"pliant":"system":"medium"="nfs" or this_computer:env:"pliant":"system":"medium"="cdrom"
                  grub_install "file:/mnt/target/" gbd gbp
                  filesystem_mount root "file:/mnt/target/" ""
                  update_rights c "file:/mnt/target/"
                  grub_configure c "file:/mnt/target/" gbd gbp root options grub_options
                  filesystem_dismount "file:/mnt/target/"
                else
                  grub_install "file:/" gbd gbp
                  update_rights c "file:/"
                  grub_configure c "file:/" gbd gbp root options grub_options
                goto_backward
              button "LILO" noeol
                var Str lilo_options := ""
                if geometry<>""
                  lilo_options += " geometry "+string:geometry
                if this_computer:env:"pliant":"system":"medium"="nfs" or this_computer:env:"pliant":"system":"medium"="cdrom"
                if this_computer:env:"pliant":"system":"medium"="nfs" or this_computer:env:"pliant":"system":"medium"="cdrom" or this_computer:env:"pliant":"system":"medium"="usb"
                  filesystem_mount root "file:/mnt/target/" ""
                  update_rights c "file:/mnt/target/"
                  var Status status := lilo_install c "file:/mnt/target/" lbd root options lilo_options
                  filesystem_dismount "file:/mnt/target/"
                else
                  update_rights c "file:/"
                  var Status status := lilo_install c "file:/" lbd root options lilo_options
                if status=success
                  goto_backward
                else
                  [Failed to make the system bootable through Lilo]
              button "none"
                goto_backward
            else
              [Only the administrator can do that !]

          if keyof:c=computer_fullname
            page button "Update settings"
              if allowed:"administrator"
                title "Update computer settings"
                var Str temp1 := file_temporary ; var Str temp2 := file_temporary
                var (Link Database:Computer) target_database :> new Database:Computer
                target_database load temp1
                data_copy c target_database:data
                target_database store
                data_store
                file_difference "security:/this_computer.pdb" temp1 temp2
                fixed
                  (var Stream s) open temp2 in+safe
                  while not s:atend
                    var Str l := s readline
                    if (l parse "-" any) or (l parse "+" any)
                      text l ; eol
                file_delete temp1 ; file_delete temp2
                button "Apply changes" noeol
                  data_copy c this_computer
                  goto_backward
                button "Cancel"
                  goto_backward
              else
                [Only the administrator can do that !]


if allowed:"administrator"
  input "Computer name: " (var Str sid) noeol
  var Str cid := ""
  button "Create the new computer" noeol
    if not (exists computer:sid)
      computer create sid
      if cid<>""
        data_copy computer:cid computer:sid
    reload_page
  button "Delete the computer"
    computer delete sid
    reload_page
  input "... as a copy of: " cid