Annotation of freem/scripts/remove_freem.sh, revision 1.1

1.1     ! snw         1: #!/usr/bin/env bash
        !             2: 
        !             3: #
        !             4: #   $Id$
        !             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$
        !            30: #
        !            31: # SPDX-FileCopyrightText:  (C) 2025 Coherent Logic Development LLC
        !            32: # SPDX-License-Identifier: AGPL-3.0-or-later
        !            33: #
        !            34: 
        !            35: PGM="$(basename $0)"
        !            36: 
        !            37: function usage() {
        !            38: 
        !            39:     echo "usage:  ${PGM} <prefix>"
        !            40:     echo
        !            41:     echo "    <prefix>"
        !            42:     echo "      - The root path where FreeM was installed."
        !            43:     echo
        !            44:     echo "        If installed from source using the defaults, this will be"
        !            45:     echo "        /usr/local on most systems."
        !            46:     echo
        !            47: 
        !            48:     exit 1
        !            49:     
        !            50: }
        !            51: 
        !            52: if [[ $# != 1 ]]
        !            53: then
        !            54:     usage
        !            55: fi
        !            56: 
        !            57: if [[ ${EUID} != 0 ]]
        !            58: then
        !            59:    echo "${PGM}:  must be run as superuser"
        !            60:    exit 1
        !            61: fi
        !            62: 
        !            63: PREFIX=$1
        !            64: 
        !            65: if [[ ! -d "${PREFIX}" ]]
        !            66: then
        !            67:     echo "${PREFIX} does not exist."
        !            68:     exit 1
        !            69: fi
        !            70: 
        !            71: FM_ETC="${PREFIX}/etc/freem"
        !            72: FM_VAR="${PREFIX}/var/freem"
        !            73: FM_FREEM="${PREFIX}/bin/freem"
        !            74: FM_FMADM="${PREFIX}/bin/fmadm"
        !            75: FM_LOGDIR="/var/log/freem"
        !            76: 
        !            77: echo "This will remove all FreeM routines, data, configurations, and binaries"
        !            78: echo "from your system."
        !            79: echo
        !            80: echo "THIS CANNOT BE UNDONE!"
        !            81: echo
        !            82: echo -n "Are you sure? (y/n) "
        !            83: read -n 1 YORN
        !            84: echo
        !            85: 
        !            86: case "${YORN}" in
        !            87:     y|Y)
        !            88:         echo "OK, removing all traces of FreeM now..."
        !            89:         ;;
        !            90:     *)
        !            91:         echo
        !            92:         echo "Doing nothing."
        !            93:         exit 1
        !            94:         ;;
        !            95: esac
        !            96: 
        !            97: echo "Stopping FreeM..."
        !            98: ${FM_FMADM} stop environment
        !            99: pkill -9 freem
        !           100: echo "Removing FreeM files..."
        !           101: 
        !           102: rm -rfv ${FM_ETC} ${FM_VAR} ${FM_FREEM} ${FM_FMADM} ${FM_LOGDIR}
        !           103: 
        !           104: echo
        !           105: echo "FreeM has been removed from your system."
        !           106: echo
        !           107: echo "You will need to reinstall from scratch and run 'fmadm configure'"
        !           108: echo "in order to use it again."
        !           109: echo

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