1: #!/usr/bin/env bash
2:
3: #
4: # $Id: freem-install.sh,v 1.2 2025/05/06 13:28:16 snw Exp $
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: freem-install.sh,v $
29: # Revision 1.2 2025/05/06 13:28:16 snw
30: # Finish Linux branch of install script
31: #
32: # Revision 1.1 2025/05/06 13:21:20 snw
33: # Add installer script
34: #
35: #
36: # SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC
37: # SPDX-License-Identifier: AGPL-3.0-or-later
38: #
39:
40: YN=no
41:
42: function yorn()
43: {
44: local prompt="$1"
45: local result=""
46:
47: echo -n "${prompt} (y/n): "
48: read -n1 result
49: echo ""
50:
51: case "${result}" in
52: y|Y)
53: YN=y
54: ;;
55: n|N)
56: YN=n
57: ;;
58: *)
59: echo "${result} is not a valid response. Please answer 'y' or 'n'."
60: yorn "${prompt}"
61: ;;
62: esac
63: }
64:
65: OS=$(uname)
66: PGM=$(basename $0)
67:
68: if [[ $EUID != 0 ]]
69: then
70: yorn "Does your account have sudo privileges?"
71: if [[ "${YN}" != "y" ]]
72: then
73: echo "${PGM}: must have sudo privileges to install FreeM"
74: exit 1
75: fi
76: else
77: echo "${PGM}: cannot install from superuser account; use your normal user account"
78: exit 1
79: fi
80:
81:
82: case ${OS} in
83:
84: Linux)
85: FM_AGEN="./autogen.sh"
86: FM_CONF="./configure"
87: FM_MAKE="make -j"
88: FM_MAKEINST="sudo make install"
89: FM_ADDGRP="sudo groupadd freem"
90: FM_ADDUSER="sudo useradd -r -g freem freem"
91: FM_CHKGRP=$(id -Gn | grep freem | wc -l)
92: FM_FIXGRP="sudo usermod -aG freem ${LOGNAME}"
93: ;;
94:
95: *)
96: echo "${PGM}: ${OS} is not supported"
97: exit 1
98: ;;
99:
100: esac
101:
102: $FM_AGEN
103: $FM_CONF
104: $FM_MAKE
105: $FM_MAKEINST
106:
107: HAVEGRP=$(cat /etc/group | egrep '^freem' | wc -l)
108: if [[ ${HAVEGRP} > 0 ]]
109: then
110: echo "${PGM}: already have 'freem' group"
111: else
112: echo "${PGM}: adding 'freem' group"
113: $FM_ADDGRP
114: fi
115:
116: HAVEUSR=$(cat /etc/passwd | egrep '^freem' | wc -l)
117: if [[ ${HAVEUSR} > 0 ]]
118: then
119: echo "${PGM}: already have 'freem' user"
120: else
121: echo "${PGM}: adding 'freem' user"
122: $FM_ADDUSER
123: fi
124:
125: if [[ $FM_CHKGRP > 0 ]]
126: then
127: GRPMSG="${PGM}: type 'freem' to run FreeM"
128: echo "${PGM}: ${LOGNAME} is already in the 'freem' group"
129: else
130: GRPMSG="${PGM}: you will need to log out and back in to run FreeM"
131: echo "${PGM}: adding ${LOGNAME} to the 'freem' group"
132: $FM_FIXGRP
133: fi
134:
135: sudo /usr/local/bin/fmadm configure
136:
137: echo "${GRPMSG}"
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>