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 (3 weeks ago) by snw
Branches: MAIN
CVS tags: HEAD
Add remove_freem.sh script

#!/usr/bin/env bash

#
#   $Id: remove_freem.sh,v 1.1 2025/05/17 19:35:30 snw Exp $
#    Removes all traces of FreeM from a system, other than
#    startup scripts.
#
#  
#   Author: Serena Willis <snw@coherent-logic.com>
#    Copyright (C) 1998 MUG Deutschland
#    Copyright (C) 2023, 2025 Coherent Logic Development LLC
#
#
#   This file is part of FreeM.
#
#   FreeM is free software: you can redistribute it and/or modify
#   it under the terms of the GNU Affero Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   FreeM is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU Affero Public License for more details.
#
#   You should have received a copy of the GNU Affero Public License
#   along with FreeM.  If not, see <https://www.gnu.org/licenses/>.
#
#   $Log: remove_freem.sh,v $
#   Revision 1.1  2025/05/17 19:35:30  snw
#   Add remove_freem.sh script
#
#
# SPDX-FileCopyrightText:  (C) 2025 Coherent Logic Development LLC
# SPDX-License-Identifier: AGPL-3.0-or-later
#

PGM="$(basename $0)"

function usage() {

    echo "usage:  ${PGM} <prefix>"
    echo
    echo "    <prefix>"
    echo "      - The root path where FreeM was installed."
    echo
    echo "        If installed from source using the defaults, this will be"
    echo "        /usr/local on most systems."
    echo

    exit 1
    
}

if [[ $# != 1 ]]
then
    usage
fi

if [[ ${EUID} != 0 ]]
then
   echo "${PGM}:  must be run as superuser"
   exit 1
fi

PREFIX=$1

if [[ ! -d "${PREFIX}" ]]
then
    echo "${PREFIX} does not exist."
    exit 1
fi

FM_ETC="${PREFIX}/etc/freem"
FM_VAR="${PREFIX}/var/freem"
FM_FREEM="${PREFIX}/bin/freem"
FM_FMADM="${PREFIX}/bin/fmadm"
FM_LOGDIR="/var/log/freem"

echo "This will remove all FreeM routines, data, configurations, and binaries"
echo "from your system."
echo
echo "THIS CANNOT BE UNDONE!"
echo
echo -n "Are you sure? (y/n) "
read -n 1 YORN
echo

case "${YORN}" in
    y|Y)
        echo "OK, removing all traces of FreeM now..."
        ;;
    *)
        echo
        echo "Doing nothing."
        exit 1
        ;;
esac

echo "Stopping FreeM..."
${FM_FMADM} stop environment
pkill -9 freem
echo "Removing FreeM files..."

rm -rfv ${FM_ETC} ${FM_VAR} ${FM_FREEM} ${FM_FMADM} ${FM_LOGDIR}

echo
echo "FreeM has been removed from your system."
echo
echo "You will need to reinstall from scratch and run 'fmadm configure'"
echo "in order to use it again."
echo

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