A few tweaks to be more distro agnostic
This commit is contained in:
parent
b90074c85d
commit
fde50bcee7
@ -71,6 +71,15 @@ if [[ "$NAME" = "Ubuntu" ]]; then
|
||||
check_os
|
||||
#check_memory
|
||||
check_ports
|
||||
elif [[ "$ID" = "openmandriva" ]]; then
|
||||
command -v dig &>/dev/null || dnf -y --refresh install bind-utils
|
||||
command -v crontab &>/dev/null || dnf -y --refresh install cronie
|
||||
# Make cronie happy
|
||||
mkdir -p /root/.cache || :
|
||||
command -v nc &>/dev/null || dnf -y --refresh install netcat
|
||||
check_docker
|
||||
check_os
|
||||
check_ports
|
||||
elif [[ "$NAME" = "Alpine Linux" ]]; then
|
||||
update_alpine
|
||||
install_packages_alpine
|
||||
@ -89,6 +98,8 @@ else
|
||||
SWAPSIZE=0
|
||||
fi
|
||||
if [ "$SWAPSIZE" -gt 0 ]; then
|
||||
touch /swap-0001
|
||||
chattr +C /swap-0001 || : # Disable copy-on-write for btrfs
|
||||
dd if=/dev/zero of=/swap-0001 bs=1M count=$SWAPSIZE
|
||||
chmod 0600 /swap-0001
|
||||
mkswap -v1 /swap-0001
|
||||
|
@ -206,9 +206,15 @@ int main(int argc, char *argv[]) {
|
||||
EOF
|
||||
|
||||
# Build .c into local statically linked binary with local glibc and gcc
|
||||
apt update
|
||||
apt install -y gcc libcrypt-dev
|
||||
gcc -static -Os -o /federated/apps/calcom/data/root/federated/static_crypt /federated/apps/calcom/data/root/federated/static_crypt.c -lcrypt
|
||||
DISTRO="$(cat /etc/os-release|grep ^ID= |cut -d= -f2 |sed -e 's,^",,;s,"$,,')"
|
||||
if [ "$DISTRO" = "ubuntu" ]; then
|
||||
apt update
|
||||
apt install -y gcc libcrypt-dev
|
||||
gcc -static -Os -o /federated/apps/calcom/data/root/federated/static_crypt /federated/apps/calcom/data/root/federated/static_crypt.c -lcrypt
|
||||
elif [ "$DISTRO" = "openmandriva" ]; then
|
||||
dnf -y --refresh install clang 'pkgconfig(libcrypt)' glibc-static-devel libcrypt-static-devel
|
||||
clang -Os -march=native -o /federated/apps/calcom/data/root/federated/static_crypt /federated/apps/calcom/data/root/federated/static_crypt.c -lcrypt
|
||||
fi
|
||||
|
||||
# Add script for applying SHA512 patches into the already built cal.com .js files
|
||||
cat > /federated/apps/calcom/data/root/federated/modify-hash-crypt-sha512.sh <<'EOOF'
|
||||
@ -743,8 +749,13 @@ EOF
|
||||
chmod 755 /federated/apps/calcom/data/root/federated/init.sh
|
||||
|
||||
# Ensure packages are installed for python requirements
|
||||
apt update
|
||||
apt install -y python3 python3-psycopg2 python3-ldap3
|
||||
DISTRO="$(cat /etc/os-release|grep ^ID= |cut -d= -f2 |sed -e 's,^",,;s,"$,,')"
|
||||
if [ "$DISTRO" = "ubuntu" ]; then
|
||||
apt update
|
||||
apt install -y python3 python3-psycopg2 python3-ldap3
|
||||
else
|
||||
dnf -y --refresh install python python-psycopg2 python-ldap3
|
||||
fi
|
||||
|
||||
# Historic addition to .env file -- to remove
|
||||
# cat >> /federated/apps/calcom/.env <<EOF
|
||||
|
@ -1329,16 +1329,21 @@ EOF
|
||||
#rm /federated/apps/mail/data/root/certs/mailfile
|
||||
}
|
||||
check_docker() {
|
||||
OSRELEASE=`lsb_release -a 2>/dev/null | grep ID | awk -F: '{ print $2 }' | xargs`
|
||||
OSRELEASE=`cat /etc/os-release|grep ^ID= |cut -d= -f2 |sed -e 's,^",,;s,"$,,'`
|
||||
|
||||
echo -ne "\n* Updating OS with the latest patches.."
|
||||
|
||||
# Update OS with latest patches
|
||||
sudo apt-get update -y &> /dev/null
|
||||
[ $? -ne 0 ] && failcheck "Couldn't run sudo apt-get update"
|
||||
if [ "$OSRELEASE" = "ubuntu" ]; then
|
||||
# Update OS with latest patches
|
||||
sudo apt-get update -y &> /dev/null
|
||||
[ $? -ne 0 ] && failcheck "Couldn't run sudo apt-get update"
|
||||
|
||||
NEEDRESTART_MODE=a apt-get upgrade -y &> /dev/null
|
||||
[ $? -ne 0 ] && failcheck "Couldn't run sudo apt-get upgrade"
|
||||
NEEDRESTART_MODE=a apt-get upgrade -y &> /dev/null
|
||||
[ $? -ne 0 ] && failcheck "Couldn't run sudo apt-get upgrade"
|
||||
elif [ "$OSRELEASE" = "openmandriva" ]; then
|
||||
dnf -y --refresh distro-sync &>/dev/null
|
||||
[ $? -ne 0 ] && failcheck "Couldn't run dnf distro-sync"
|
||||
fi
|
||||
|
||||
kill -9 $SPINPID &> /dev/null
|
||||
echo -ne "done."
|
||||
@ -1350,7 +1355,7 @@ check_docker() {
|
||||
SPINPID=$!
|
||||
|
||||
# Install Docker on Ubuntu
|
||||
if [ $OSRELEASE == "Ubuntu" ]; then
|
||||
if [ $OSRELEASE == "ubuntu" ]; then
|
||||
# Update list of packages
|
||||
sudo apt-get update -y &> /dev/null
|
||||
[ $? -ne 0 ] && failcheck "Couldn't run sudo apt-get update"
|
||||
@ -1375,12 +1380,8 @@ check_docker() {
|
||||
sudo apt-get install duplicity python3-b2sdk uuid apache2-utils -y &> /dev/null
|
||||
[ $? -ne 0 ] && failcheck "Couldn't run sudo apt install extra packages"
|
||||
|
||||
# Install Traefik certs dumper
|
||||
curl -sfL https://raw.githubusercontent.com/ldez/traefik-certs-dumper/master/godownloader.sh | bash -s -- -b $(go env GOPATH 2>/dev/null)/bin v2.8.1 &> /dev/null
|
||||
[ $? -ne 0 ] && failcheck "Couldn't install traefik certs dumper"
|
||||
|
||||
# Put in log rotation fix for docker container logs
|
||||
cat > /etc/docker/daemon.json <<EOF
|
||||
cat > /etc/docker/daemon.json <<EOF
|
||||
{
|
||||
"log-driver": "json-file",
|
||||
"log-opts": {
|
||||
@ -1390,10 +1391,20 @@ cat > /etc/docker/daemon.json <<EOF
|
||||
}
|
||||
EOF
|
||||
|
||||
# Restart docker daemon
|
||||
systemctl restart docker
|
||||
# Install Traefik certs dumper
|
||||
curl -sfL https://raw.githubusercontent.com/ldez/traefik-certs-dumper/master/godownloader.sh | bash -s -- -b $(go env GOPATH 2>/dev/null)/bin v2.8.1 &> /dev/null
|
||||
[ $? -ne 0 ] && failcheck "Couldn't install traefik certs dumper"
|
||||
|
||||
elif [ "$OSRELEASE" = "openmandriva" ]; then
|
||||
dnf -y --refresh install docker curl docker-compose traefik-certs-dumper
|
||||
sed -i -e "s,^OPTIONS=.*,OPTIONS='--log-opt max-size=200m --log-opt max-file=3'," /etc/sysconfig/docker
|
||||
|
||||
systemctl start docker
|
||||
fi
|
||||
|
||||
# Restart docker daemon
|
||||
systemctl restart docker
|
||||
|
||||
kill -9 $SPINPID &> /dev/null
|
||||
echo -ne "done."
|
||||
fi
|
||||
@ -1404,8 +1415,10 @@ EOF
|
||||
SPINPID=$!
|
||||
|
||||
# Install Docker compose on Ubuntu
|
||||
if [ $OSRELEASE == "Ubuntu" ]; then
|
||||
if [ $OSRELEASE == "ubuntu" ]; then
|
||||
sudo apt-get install docker-compose -y &> /dev/null
|
||||
elif [ $OSRELEASE = "openmandriva" ]; then
|
||||
sudo dnf -y --refresh install docker-compose &>/dev/null
|
||||
fi
|
||||
|
||||
kill -9 $SPINPID &> /dev/null
|
||||
@ -1424,33 +1437,34 @@ check_ports() {
|
||||
SS=`ss -tulwn | grep LISTEN | awk '{ print $5 }' | awk -F: '{ print $NF }' | grep "^$i$" | head -1`
|
||||
# If port 53 (dns) in use by system-resolvd (Ubuntu) then auto fix
|
||||
if [ "$SS" == 53 ]; then
|
||||
if [ $OSRELEASE == "Ubuntu" ]; then
|
||||
echo -ne "\n* Port 53 in use by systemd-resolved, fixing.."
|
||||
spin &
|
||||
SPINPID=$!
|
||||
if [ $OSRELEASE == "ubuntu" ]; then
|
||||
if [ `pgrep -x systemd-resolve` ]; then
|
||||
echo -ne "\n* Port 53 in use by systemd-resolved, fixing.."
|
||||
spin &
|
||||
SPINPID=$!
|
||||
|
||||
# Install resolvconf to fix
|
||||
sudo apt install resolvconf -y &> /dev/null
|
||||
[ $? -eq 0 ] && echo -ne "." || failcheck "Failed running sudo apt install resolvconf"
|
||||
|
||||
# Shut down systemd-resolved
|
||||
systemctl stop systemd-resolved &> /dev/null
|
||||
[ $? -ne 0 ] && failcheck "Failed running systemctl stop systemd-resolved"
|
||||
systemctl disable systemd-resolved &> /dev/null
|
||||
[ $? -ne 0 ] && failcheck "Failed running systemctl stop systemd-resolved"
|
||||
|
||||
# Put nameserver entries so will exist on reboot
|
||||
rm /etc/resolv.conf
|
||||
echo "nameserver 1.1.1.1" >> /etc/resolv.conf
|
||||
echo "nameserver 1.0.0.1" >> /etc/resolv.conf
|
||||
|
||||
kill -9 $SPINPID &> /dev/null
|
||||
echo -ne "done."
|
||||
else
|
||||
echo -ne "\nFAILED - Port 53 (dns) is already in use\n\n" && exit 2
|
||||
fi
|
||||
elif [ $OSRELEASE == "openmandriva" ]; then
|
||||
systemctl disable --now systemd-resolved
|
||||
fi
|
||||
# Shut down systemd-resolved
|
||||
systemctl stop systemd-resolved &> /dev/null
|
||||
[ $? -ne 0 ] && failcheck "Failed running systemctl stop systemd-resolved"
|
||||
systemctl disable systemd-resolved &> /dev/null
|
||||
[ $? -ne 0 ] && failcheck "Failed running systemctl disable systemd-resolved"
|
||||
# Put nameserver entries so will exist on reboot
|
||||
rm /etc/resolv.conf
|
||||
echo "nameserver 1.1.1.1" >> /etc/resolv.conf
|
||||
echo "nameserver 1.0.0.1" >> /etc/resolv.conf
|
||||
|
||||
kill -9 $SPINPID &> /dev/null
|
||||
echo -ne "done."
|
||||
elif [ "$SS" == "$i" ]; then
|
||||
failcheck "FAILED - Port $i is already in use"
|
||||
fi
|
||||
@ -1459,8 +1473,9 @@ check_ports() {
|
||||
fi
|
||||
}
|
||||
check_os() {
|
||||
OSRELEASE=`cat /etc/os-release|grep ^ID= |cut -d= -f2 |sed -e 's,^",,;s,"$,,'`
|
||||
VERSIONID=`grep "VERSION_ID=" /etc/os-release | awk -F\" '{ print $2 }'`
|
||||
if [ "$VERSIONID" != "22.04" ]; then
|
||||
if [ "$OSRELEASE" = "ubuntu" -a "$VERSIONID" != "22.04" ]; then
|
||||
echo -ne "\nFederated requires a minimum of 4G of RAM and 25G of storage\n \
|
||||
running Ubuntu 22.04 LTS. Your system is not supported. Please contact\n \
|
||||
Federated @ support@federated.computer for assistance or choose our\n \
|
||||
@ -1484,7 +1499,7 @@ get_installedapps() {
|
||||
get_appvars() {
|
||||
BUNDLE=$(egrep "TIER|BUNDLE" /etc/federated | awk -F\" '{ print $2 }')
|
||||
LDAP_SECRET=`cat /federated/apps/ldap/.ldap.secret`
|
||||
EXTERNALIP=$(get_externalip);
|
||||
EXTERNALIP=$(get_externalip)
|
||||
MYSQL_ROOTPASSWORD=`cat /federated/apps/pdnsmysql/.env | grep MYSQL_ROOT_PASSWORD | awk -F= '{ print $2 }'`
|
||||
|
||||
# If ADMINPASS doesn't exist in /etc/federated then use nextcloud to get it. Otherwise get it from /etc/federated
|
||||
|
Loading…
x
Reference in New Issue
Block a user