Delete Sites

  • Creator
    Topic
  • #47919
    Charlie Bursell
    Participant

    I have had a couple of people ask me about this so I am uploading the script I use to delete a site from the command line.

    Just put this script in your $HCIROOT/contrib directory.  run as rmSite

    It removes the directory and the entry from the server.ini file.  If you are  not the owner of the site, run as root or, prior to run do “chown -R hci as root.  This assumes you want everything owned by user hci.

    If running from a pre-5.x Cloverleaf version, you will have to change the second line in the script.

    It will work just as well from Windows.  Simply rename the script to rmSite.htc

    Charlie

Viewing 5 reply threads
  • Author
    Replies
    • #57079
      Michael Stankov
      Participant

      Hi,

      I’m in a windows environment and can’t delete sites with the script. I get permission denied everytime??

    • #57080
      Charlie Bursell
      Participant

      Make sure you are not in the site or have anything else accessing the site

    • #57081
      Michael Stankov
      Participant

      Yep  ðŸ˜³ , it worked!! Thanks

    • #57082
      Jeff Manley
      Participant

      The only thing that scares me about the code above is that it might delete the directory, but for some unknown reason, not able to delete the site from the server file.  If that happens, problems could arise.

      Would it be better to delete the site from the server file and if that went ok, then delete the directory?

    • #57083
      Charlie Bursell
      Participant

      The code will delete from the server.ini.  If some reason it cannot, it will provide an error message.

      The more common error woul be not able to delete the directory because it is being used by another program

    • #57084
      Russ Ross
      Participant

      Charlie’s rmSite script reminded me of one of my home grown scripts ( set_server_ini_environs.ksh ) I wrote to help me keep my server.ini entries in sorted order.

      It can also be run to refresh your server.ini file to accurately reflect the current cloverleaf sites at the time it is run in the event you have deleted, created, or renamed a cloverleaf site on the back-end.

      I’ve used it for more than a couple of years with success and found it especially helpful when upgrading the hundreds of cloverleaf sites we have.

      Here is set_server_ini_environs.ksh

      Code:

      #!/usr/bin/ksh

      # the purpose of this script is to set the environs variable in the server.ini file
      # so that it has all our Cloverleaf sites in sorted order

      # History:
      #
      # 2005.08.17 Russ Ross wrote initial version
      #

      cp -p $HCIROOT/server/server.ini
           $HCIROOT/server/server.ini_`date +”%Y.%m.%d_%H:%M:%S”`

      perl -pi -e “s,^environs=.*$,`mk_server_ini_environs.ksh`,”
           $HCIROOT/server/server.ini

      which calls mk_server_ini_environs.ksh

      Code:

      #!/usr/bin/ksh

      # the purpose of this script is to create the statement to initialize the environs variable
      # which can be redirected to a temp file like x.x and then manually inserted
      # into the server.ini file so the Cloverleaf sites will appear in sorted order in the GUI

      # History:
      #
      # 2005.06.21 Russ Ross wrote initial version

      envorns_statement=”environs=”
      for site in `list_sites.ksh`; do
          envorns_statement=”$envorns_statement$HCIROOT/$site;”
      done
      echo “$envorns_statement” | perl -pi -e “s/;$//”

      which calls list_sites.ksh

      Code:

      #!/usr/bin/ksh

      # Begin Module Header ==============================================================================
      #
      #——
      # Name:
      #——
      #
      # list_sites.ksh
      #
      #———
      # Purpose:
      #———
      #
      # List all the sites for the current $HCIROOT
      #
      #——–
      # Inputs:
      #——–
      #
      # none
      #
      #——-
      # Notes:
      #——-
      #
      # This script assumes the proper environment is set when it is called
      # and all sites are symbolic links at the $HCIROOT level
      #
      #———
      # History:
      #———
      #
      # 2001.02.22 Russ Ross
      #          – wrote initial version.
      #
      # 2001.07.25 Russ Ross
      #          – modified to look for $HCIROOT/*/siteInfo files to determine the list of sites,
      #            previously had looked for symbolic links in the $HCIROOT directory which only
      #            works if everyone follows MDACC conventions
      #
      # 2003.11.17 Russ Ross
      #          – modified to execlude siteProto from the list of sites
      #
      # End of Module Header =============================================================================

      #—————————————————————————————–
      # get a list of all the sites for the current $HCIROOT
      # (Note:  there is an assumption that all sites are a symbolic link at the $HCIROOT level)
      #—————————————————————————————–

      (cd $HCIROOT; ls ./*/siteInfo 2>/dev/null) | awk -F/ ‘{print $2}’ | grep -v siteProto | sort

      Russ Ross
      RussRoss318@gmail.com

Viewing 5 reply threads
  • The forum ‘Tcl Library’ is closed to new topics and replies.

Forum Statistics

Registered Users
5,127
Forums
28
Topics
9,299
Replies
34,443
Topic Tags
288
Empty Topic Tags
10