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_os
|
||||||
#check_memory
|
#check_memory
|
||||||
check_ports
|
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
|
elif [[ "$NAME" = "Alpine Linux" ]]; then
|
||||||
update_alpine
|
update_alpine
|
||||||
install_packages_alpine
|
install_packages_alpine
|
||||||
@ -89,6 +98,8 @@ else
|
|||||||
SWAPSIZE=0
|
SWAPSIZE=0
|
||||||
fi
|
fi
|
||||||
if [ "$SWAPSIZE" -gt 0 ]; then
|
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
|
dd if=/dev/zero of=/swap-0001 bs=1M count=$SWAPSIZE
|
||||||
chmod 0600 /swap-0001
|
chmod 0600 /swap-0001
|
||||||
mkswap -v1 /swap-0001
|
mkswap -v1 /swap-0001
|
||||||
|
@ -206,9 +206,15 @@ int main(int argc, char *argv[]) {
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Build .c into local statically linked binary with local glibc and gcc
|
# Build .c into local statically linked binary with local glibc and gcc
|
||||||
|
DISTRO="$(cat /etc/os-release|grep ^ID= |cut -d= -f2 |sed -e 's,^",,;s,"$,,')"
|
||||||
|
if [ "$DISTRO" = "ubuntu" ]; then
|
||||||
apt update
|
apt update
|
||||||
apt install -y gcc libcrypt-dev
|
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
|
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
|
# 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'
|
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
|
chmod 755 /federated/apps/calcom/data/root/federated/init.sh
|
||||||
|
|
||||||
# Ensure packages are installed for python requirements
|
# Ensure packages are installed for python requirements
|
||||||
|
DISTRO="$(cat /etc/os-release|grep ^ID= |cut -d= -f2 |sed -e 's,^",,;s,"$,,')"
|
||||||
|
if [ "$DISTRO" = "ubuntu" ]; then
|
||||||
apt update
|
apt update
|
||||||
apt install -y python3 python3-psycopg2 python3-ldap3
|
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
|
# Historic addition to .env file -- to remove
|
||||||
# cat >> /federated/apps/calcom/.env <<EOF
|
# cat >> /federated/apps/calcom/.env <<EOF
|
||||||
|
@ -1329,16 +1329,21 @@ EOF
|
|||||||
#rm /federated/apps/mail/data/root/certs/mailfile
|
#rm /federated/apps/mail/data/root/certs/mailfile
|
||||||
}
|
}
|
||||||
check_docker() {
|
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.."
|
echo -ne "\n* Updating OS with the latest patches.."
|
||||||
|
|
||||||
|
if [ "$OSRELEASE" = "ubuntu" ]; then
|
||||||
# Update OS with latest patches
|
# Update OS with latest patches
|
||||||
sudo apt-get update -y &> /dev/null
|
sudo apt-get update -y &> /dev/null
|
||||||
[ $? -ne 0 ] && failcheck "Couldn't run sudo apt-get update"
|
[ $? -ne 0 ] && failcheck "Couldn't run sudo apt-get update"
|
||||||
|
|
||||||
NEEDRESTART_MODE=a apt-get upgrade -y &> /dev/null
|
NEEDRESTART_MODE=a apt-get upgrade -y &> /dev/null
|
||||||
[ $? -ne 0 ] && failcheck "Couldn't run sudo apt-get upgrade"
|
[ $? -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
|
kill -9 $SPINPID &> /dev/null
|
||||||
echo -ne "done."
|
echo -ne "done."
|
||||||
@ -1350,7 +1355,7 @@ check_docker() {
|
|||||||
SPINPID=$!
|
SPINPID=$!
|
||||||
|
|
||||||
# Install Docker on Ubuntu
|
# Install Docker on Ubuntu
|
||||||
if [ $OSRELEASE == "Ubuntu" ]; then
|
if [ $OSRELEASE == "ubuntu" ]; then
|
||||||
# Update list of packages
|
# Update list of packages
|
||||||
sudo apt-get update -y &> /dev/null
|
sudo apt-get update -y &> /dev/null
|
||||||
[ $? -ne 0 ] && failcheck "Couldn't run sudo apt-get update"
|
[ $? -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
|
sudo apt-get install duplicity python3-b2sdk uuid apache2-utils -y &> /dev/null
|
||||||
[ $? -ne 0 ] && failcheck "Couldn't run sudo apt install extra packages"
|
[ $? -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
|
# 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-driver": "json-file",
|
||||||
"log-opts": {
|
"log-opts": {
|
||||||
@ -1390,10 +1391,20 @@ cat > /etc/docker/daemon.json <<EOF
|
|||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
# 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
|
# Restart docker daemon
|
||||||
systemctl restart docker
|
systemctl restart docker
|
||||||
|
|
||||||
fi
|
|
||||||
kill -9 $SPINPID &> /dev/null
|
kill -9 $SPINPID &> /dev/null
|
||||||
echo -ne "done."
|
echo -ne "done."
|
||||||
fi
|
fi
|
||||||
@ -1404,8 +1415,10 @@ EOF
|
|||||||
SPINPID=$!
|
SPINPID=$!
|
||||||
|
|
||||||
# Install Docker compose on Ubuntu
|
# Install Docker compose on Ubuntu
|
||||||
if [ $OSRELEASE == "Ubuntu" ]; then
|
if [ $OSRELEASE == "ubuntu" ]; then
|
||||||
sudo apt-get install docker-compose -y &> /dev/null
|
sudo apt-get install docker-compose -y &> /dev/null
|
||||||
|
elif [ $OSRELEASE = "openmandriva" ]; then
|
||||||
|
sudo dnf -y --refresh install docker-compose &>/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
kill -9 $SPINPID &> /dev/null
|
kill -9 $SPINPID &> /dev/null
|
||||||
@ -1424,22 +1437,27 @@ check_ports() {
|
|||||||
SS=`ss -tulwn | grep LISTEN | awk '{ print $5 }' | awk -F: '{ print $NF }' | grep "^$i$" | head -1`
|
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 port 53 (dns) in use by system-resolvd (Ubuntu) then auto fix
|
||||||
if [ "$SS" == 53 ]; then
|
if [ "$SS" == 53 ]; then
|
||||||
if [ $OSRELEASE == "Ubuntu" ]; then
|
|
||||||
if [ `pgrep -x systemd-resolve` ]; then
|
|
||||||
echo -ne "\n* Port 53 in use by systemd-resolved, fixing.."
|
echo -ne "\n* Port 53 in use by systemd-resolved, fixing.."
|
||||||
spin &
|
spin &
|
||||||
SPINPID=$!
|
SPINPID=$!
|
||||||
|
if [ $OSRELEASE == "ubuntu" ]; then
|
||||||
|
if [ `pgrep -x systemd-resolve` ]; then
|
||||||
# Install resolvconf to fix
|
# Install resolvconf to fix
|
||||||
sudo apt install resolvconf -y &> /dev/null
|
sudo apt install resolvconf -y &> /dev/null
|
||||||
[ $? -eq 0 ] && echo -ne "." || failcheck "Failed running sudo apt install resolvconf"
|
[ $? -eq 0 ] && echo -ne "." || failcheck "Failed running sudo apt install resolvconf"
|
||||||
|
|
||||||
|
|
||||||
|
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
|
# Shut down systemd-resolved
|
||||||
systemctl stop systemd-resolved &> /dev/null
|
systemctl stop systemd-resolved &> /dev/null
|
||||||
[ $? -ne 0 ] && failcheck "Failed running systemctl stop systemd-resolved"
|
[ $? -ne 0 ] && failcheck "Failed running systemctl stop systemd-resolved"
|
||||||
systemctl disable systemd-resolved &> /dev/null
|
systemctl disable systemd-resolved &> /dev/null
|
||||||
[ $? -ne 0 ] && failcheck "Failed running systemctl stop systemd-resolved"
|
[ $? -ne 0 ] && failcheck "Failed running systemctl disable systemd-resolved"
|
||||||
|
|
||||||
# Put nameserver entries so will exist on reboot
|
# Put nameserver entries so will exist on reboot
|
||||||
rm /etc/resolv.conf
|
rm /etc/resolv.conf
|
||||||
echo "nameserver 1.1.1.1" >> /etc/resolv.conf
|
echo "nameserver 1.1.1.1" >> /etc/resolv.conf
|
||||||
@ -1447,10 +1465,6 @@ check_ports() {
|
|||||||
|
|
||||||
kill -9 $SPINPID &> /dev/null
|
kill -9 $SPINPID &> /dev/null
|
||||||
echo -ne "done."
|
echo -ne "done."
|
||||||
else
|
|
||||||
echo -ne "\nFAILED - Port 53 (dns) is already in use\n\n" && exit 2
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
elif [ "$SS" == "$i" ]; then
|
elif [ "$SS" == "$i" ]; then
|
||||||
failcheck "FAILED - Port $i is already in use"
|
failcheck "FAILED - Port $i is already in use"
|
||||||
fi
|
fi
|
||||||
@ -1459,8 +1473,9 @@ check_ports() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
check_os() {
|
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 }'`
|
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 \
|
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 \
|
running Ubuntu 22.04 LTS. Your system is not supported. Please contact\n \
|
||||||
Federated @ support@federated.computer for assistance or choose our\n \
|
Federated @ support@federated.computer for assistance or choose our\n \
|
||||||
@ -1484,7 +1499,7 @@ get_installedapps() {
|
|||||||
get_appvars() {
|
get_appvars() {
|
||||||
BUNDLE=$(egrep "TIER|BUNDLE" /etc/federated | awk -F\" '{ print $2 }')
|
BUNDLE=$(egrep "TIER|BUNDLE" /etc/federated | awk -F\" '{ print $2 }')
|
||||||
LDAP_SECRET=`cat /federated/apps/ldap/.ldap.secret`
|
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 }'`
|
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
|
# 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