File:  [Coherent Logic Development] / freem / scripts / remove_freem.sh
Revision 1.1: download - view: text, annotated - select for diffs
Sat May 17 19:35:30 2025 UTC (2 months, 2 weeks ago) by snw
Branches: MAIN
CVS tags: HEAD
Add remove_freem.sh script

    1: #!/usr/bin/env bash
    2: 
    3: #
    4: #   $Id: remove_freem.sh,v 1.1 2025/05/17 19:35:30 snw Exp $
    5: #    Removes all traces of FreeM from a system, other than
    6: #    startup scripts.
    7: #
    8: #  
    9: #   Author: Serena Willis <snw@coherent-logic.com>
   10: #    Copyright (C) 1998 MUG Deutschland
   11: #    Copyright (C) 2023, 2025 Coherent Logic Development LLC
   12: #
   13: #
   14: #   This file is part of FreeM.
   15: #
   16: #   FreeM is free software: you can redistribute it and/or modify
   17: #   it under the terms of the GNU Affero Public License as published by
   18: #   the Free Software Foundation, either version 3 of the License, or
   19: #   (at your option) any later version.
   20: #
   21: #   FreeM is distributed in the hope that it will be useful,
   22: #   but WITHOUT ANY WARRANTY; without even the implied warranty of
   23: #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   24: #   GNU Affero Public License for more details.
   25: #
   26: #   You should have received a copy of the GNU Affero Public License
   27: #   along with FreeM.  If not, see <https://www.gnu.org/licenses/>.
   28: #
   29: #   $Log: remove_freem.sh,v $
   30: #   Revision 1.1  2025/05/17 19:35:30  snw
   31: #   Add remove_freem.sh script
   32: #
   33: #
   34: # SPDX-FileCopyrightText:  (C) 2025 Coherent Logic Development LLC
   35: # SPDX-License-Identifier: AGPL-3.0-or-later
   36: #
   37: 
   38: PGM="$(basename $0)"
   39: 
   40: function usage() {
   41: 
   42:     echo "usage:  ${PGM} <prefix>"
   43:     echo
   44:     echo "    <prefix>"
   45:     echo "      - The root path where FreeM was installed."
   46:     echo
   47:     echo "        If installed from source using the defaults, this will be"
   48:     echo "        /usr/local on most systems."
   49:     echo
   50: 
   51:     exit 1
   52:     
   53: }
   54: 
   55: if [[ $# != 1 ]]
   56: then
   57:     usage
   58: fi
   59: 
   60: if [[ ${EUID} != 0 ]]
   61: then
   62:    echo "${PGM}:  must be run as superuser"
   63:    exit 1
   64: fi
   65: 
   66: PREFIX=$1
   67: 
   68: if [[ ! -d "${PREFIX}" ]]
   69: then
   70:     echo "${PREFIX} does not exist."
   71:     exit 1
   72: fi
   73: 
   74: FM_ETC="${PREFIX}/etc/freem"
   75: FM_VAR="${PREFIX}/var/freem"
   76: FM_FREEM="${PREFIX}/bin/freem"
   77: FM_FMADM="${PREFIX}/bin/fmadm"
   78: FM_LOGDIR="/var/log/freem"
   79: 
   80: echo "This will remove all FreeM routines, data, configurations, and binaries"
   81: echo "from your system."
   82: echo
   83: echo "THIS CANNOT BE UNDONE!"
   84: echo
   85: echo -n "Are you sure? (y/n) "
   86: read -n 1 YORN
   87: echo
   88: 
   89: case "${YORN}" in
   90:     y|Y)
   91:         echo "OK, removing all traces of FreeM now..."
   92:         ;;
   93:     *)
   94:         echo
   95:         echo "Doing nothing."
   96:         exit 1
   97:         ;;
   98: esac
   99: 
  100: echo "Stopping FreeM..."
  101: ${FM_FMADM} stop environment
  102: pkill -9 freem
  103: echo "Removing FreeM files..."
  104: 
  105: rm -rfv ${FM_ETC} ${FM_VAR} ${FM_FREEM} ${FM_FMADM} ${FM_LOGDIR}
  106: 
  107: echo
  108: echo "FreeM has been removed from your system."
  109: echo
  110: echo "You will need to reinstall from scratch and run 'fmadm configure'"
  111: echo "in order to use it again."
  112: echo

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>