#!/usr/bin/env bash
#
# $Id: freem-install.sh,v 1.1 2025/05/06 13:21:20 snw Exp $
# FreeM source installer
#
#
# 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: freem-install.sh,v $
# Revision 1.1 2025/05/06 13:21:20 snw
# Add installer script
#
#
# SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC
# SPDX-License-Identifier: AGPL-3.0-or-later
#
YN=no
function yorn()
{
local prompt="$1"
local result=""
echo -n "${prompt} (y/n): "
read -n1 result
echo ""
case "${result}" in
y|Y)
YN=y
;;
n|N)
YN=n
;;
*)
echo "${result} is not a valid response. Please answer 'y' or 'n'."
yorn "${prompt}"
;;
esac
}
OS=$(uname)
PGM=$(basename $0)
if [[ $EUID != 0 ]]
then
yorn "Does your account have sudo privileges?"
if [[ "${YN}" != "y" ]]
then
exit 1
fi
fi
case ${OS} in
Linux)
FM_AGEN="./autogen.sh"
FM_CONF="./configure"
FM_MAKE="make -j"
FM_MAKEINST="sudo make install"
FM_ADDGRP="sudo groupadd freem"
FM_ADDUSER="sudo useradd -r -g freem freem"
FM_CHKGRP="id -Gn | grep freem | wc -l"
FM_FIXGRP="sudo usermod -aG freem ${LOGNAME}"
;;
*)
echo "${PGM}: ${OS} is not supported"
exit 1
;;
esac
$FM_AGEN
$FM_CONF
$FM_MAKE
$FM_MAKEINST
HAVEGRP=$(cat /etc/group | egrep '^freem' | wc -l)
if [[ ${HAVEGRP} > 0 ]]
then
echo "${PGM}: already have 'freem' group"
else
echo "${PGM}: adding 'freem' group"
$FM_ADDGRP
fi
HAVEUSR=$(cat /etc/passwd | egrep '^freem' | wc -l)
if [[ ${HAVEUSR} > 0 ]]
then
echo "${PGM}: already have 'freem' user"
else
echo "${PGM}: adding 'freem' user"
$FM_ADDUSER
fi
INGROUP=$($FM_CHKGRP)
if [[ $INGROUP > 0 ]]
then
GRPMSG="${PGM}: type 'freem' to run FreeM"
echo "${PGM}: ${LOGNAME} is already in the 'freem' group"
else
GRPMSG="${PGM}: you will need to log out and back in to run FreeM"
echo "${PGM}: adding ${LOGNAME} to the 'freem' group"
$FM_FIXGRP
fi
sudo /usr/local/bin/fmadm configure
echo "${GRPMSG}"
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>