Annotation of freem/freem-install.sh, revision 1.1

1.1     ! snw         1: #!/usr/bin/env bash
        !             2: 
        !             3: #
        !             4: #   $Id$
        !             5: #    FreeM source installer
        !             6: #
        !             7: #  
        !             8: #   Author: Serena Willis <snw@coherent-logic.com>
        !             9: #    Copyright (C) 1998 MUG Deutschland
        !            10: #    Copyright (C) 2023, 2025 Coherent Logic Development LLC
        !            11: #
        !            12: #
        !            13: #   This file is part of FreeM.
        !            14: #
        !            15: #   FreeM is free software: you can redistribute it and/or modify
        !            16: #   it under the terms of the GNU Affero Public License as published by
        !            17: #   the Free Software Foundation, either version 3 of the License, or
        !            18: #   (at your option) any later version.
        !            19: #
        !            20: #   FreeM is distributed in the hope that it will be useful,
        !            21: #   but WITHOUT ANY WARRANTY; without even the implied warranty of
        !            22: #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        !            23: #   GNU Affero Public License for more details.
        !            24: #
        !            25: #   You should have received a copy of the GNU Affero Public License
        !            26: #   along with FreeM.  If not, see <https://www.gnu.org/licenses/>.
        !            27: #
        !            28: #   $Log$
        !            29: #
        !            30: # SPDX-FileCopyrightText:  (C) 2025 Coherent Logic Development LLC
        !            31: # SPDX-License-Identifier: AGPL-3.0-or-later
        !            32: #
        !            33: 
        !            34: YN=no
        !            35: 
        !            36: function yorn()
        !            37: {
        !            38:     local prompt="$1"
        !            39:     local result=""
        !            40:     
        !            41:     echo -n "${prompt} (y/n): "
        !            42:     read -n1 result
        !            43:     echo ""
        !            44:     
        !            45:     case "${result}" in
        !            46:         y|Y)
        !            47:             YN=y
        !            48:             ;;
        !            49:         n|N)
        !            50:             YN=n
        !            51:             ;;
        !            52:         *)
        !            53:             echo "${result} is not a valid response. Please answer 'y' or 'n'."
        !            54:             yorn "${prompt}"
        !            55:             ;;
        !            56:     esac
        !            57: }
        !            58: 
        !            59: OS=$(uname)
        !            60: PGM=$(basename $0)
        !            61: 
        !            62: if [[ $EUID != 0 ]]
        !            63: then
        !            64:     yorn "Does your account have sudo privileges?"
        !            65:     if [[ "${YN}" != "y" ]]
        !            66:     then       
        !            67:         exit 1
        !            68:     fi
        !            69: fi
        !            70: 
        !            71: 
        !            72: case ${OS} in
        !            73: 
        !            74:     Linux)
        !            75:         FM_AGEN="./autogen.sh"
        !            76:         FM_CONF="./configure"
        !            77:         FM_MAKE="make -j"
        !            78:         FM_MAKEINST="sudo make install"
        !            79:         FM_ADDGRP="sudo groupadd freem"
        !            80:         FM_ADDUSER="sudo useradd -r -g freem freem"
        !            81:         FM_CHKGRP="id -Gn | grep freem | wc -l"
        !            82:         FM_FIXGRP="sudo usermod -aG freem ${LOGNAME}"
        !            83:         ;;
        !            84: 
        !            85:     *)
        !            86:         echo "${PGM}:  ${OS} is not supported"
        !            87:         exit 1
        !            88:         ;;
        !            89:     
        !            90: esac
        !            91: 
        !            92: $FM_AGEN
        !            93: $FM_CONF
        !            94: $FM_MAKE
        !            95: $FM_MAKEINST
        !            96: 
        !            97: HAVEGRP=$(cat /etc/group | egrep '^freem' | wc -l)
        !            98: if [[ ${HAVEGRP} > 0 ]]
        !            99: then
        !           100:     echo "${PGM}:  already have 'freem' group"
        !           101: else
        !           102:     echo "${PGM}:  adding 'freem' group"
        !           103:     $FM_ADDGRP
        !           104: fi
        !           105: 
        !           106: HAVEUSR=$(cat /etc/passwd | egrep '^freem' | wc -l)
        !           107: if [[ ${HAVEUSR} > 0 ]]
        !           108: then
        !           109:     echo "${PGM}:  already have 'freem' user"
        !           110: else
        !           111:     echo "${PGM}:  adding 'freem' user"
        !           112:     $FM_ADDUSER
        !           113: fi
        !           114: 
        !           115: INGROUP=$($FM_CHKGRP)
        !           116: if [[ $INGROUP > 0 ]]
        !           117: then
        !           118:     GRPMSG="${PGM}:  type 'freem' to run FreeM"
        !           119:     echo "${PGM}:  ${LOGNAME} is already in the 'freem' group"
        !           120: else
        !           121:     GRPMSG="${PGM}:  you will need to log out and back in to run FreeM"
        !           122:     echo "${PGM}:  adding ${LOGNAME} to the 'freem' group"
        !           123:     $FM_FIXGRP    
        !           124: fi
        !           125: 
        !           126: sudo /usr/local/bin/fmadm configure
        !           127: 
        !           128: echo "${GRPMSG}"

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