wmde-rp/install.sh

107 lines
2.4 KiB
Bash
Executable File

#!/bin/sh
if [ -f /etc/os-release ]; then
. /etc/os-release
DISTRO=$ID
if [ "$DISTRO" = "ubuntu" ] || [ "$DISTRO" = "debian" ]; then
OS=DEBIAN
elif [ "$DISTRO" = "fedora" ] || [ "$DISTRO" = "centos" ]; then
OS=CENTOS
else
echo "OS not detected"
exit 1
fi
else
echo "/etc/os-release not found, cannot determine OS."
exit 1
fi
PREFIX=/usr/local/bin/wmde
copy_files() {
mkdir -p $PREFIX
cp wmde-rp-init.sh $PREFIX/
cp wmde-rp-check-pam-user.sh $PREFIX/
#cp wmde-rp-unison-initial-sync-nfs.sh $PREFIX/
cp wmde-rp-generate-known-hosts.sh $PREFIX/
#cp wmde-rp-usersync-nfs.sh $PREFIX/
cp wmde-rp-unison-ssh.sh $PREFIX/
cp wmde-rp-common.sh $PREFIX/
cp wmde-rp-osync-ssh.sh $PREFIX/
chmod 755 $PREFIX/*
cp osync.conf.template $PREFIX/
cp wmde-rp-sync.service /etc/systemd/user/wmde-rp-sync.service
mkdir -p /etc/systemd/user/default.target.wants
rm -rf /etc/systemd/user/default.target.wants/wmde-rp-sync.service
ln -s /etc/systemd/user/wmde-rp-sync.service /etc/systemd/user/default.target.wants/wmde-rp-sync.service
# cp wmde-rp-full.prf /etc
# cp wmde-rp-config.prf /etc
# cp wmde-rp-perm.prf /etc
cp wmde-rp.conf /etc
git clone https://srcsrv.wikimedia.de/WMDE/osync.git /tmp/osync
cp -p /tmp/osync/osync.sh /usr/local/bin/osync.sh
chmod 755 /usr/local/bin/osync.sh
systemctl daemon-reload
}
update_pam() {
rm -rf /etc/authselect/custom/wmde
authselect create-profile wmde -b sssd --symlink-meta
cp postlogin /etc/authselect/custom/wmde/postlogin
authselect select custom/wmde with-mkhomedir with-sudo
authselect apply-changes
}
if [ "$OS" = "CENTOS" ]; then
dnf install -y unison
copy_files
update_pam
fi
if [ "$OS" = "DEBIAN" ]; then
apt purge -y unison
mkdir -p unison_temp
cd unison_temp
wget https://github.com/bcpierce00/unison/releases/download/v2.53.7/unison-2.53.7-ubuntu-x86_64-static.tar.gz
tar xvfz unison-2.53.7-ubuntu-x86_64-static.tar.gz
cd bin
chmod +x unison unison-fsmonitor
sudo mv unison unison-fsmonitor /usr/local/bin/
cd ..
cd ..
rm -rf unison_temp
copy_files
FILE="/etc/pam.d/common-session"
LINE="session required pam_exec.so stdout /usr/local/bin/wmde/wmde-rp-init.sh"
FOUND=0
# Datei zeilenweise prüfen
while IFS= read -r existing_line; do
if [ "$existing_line" = "$LINE" ]; then
FOUND=1
break
fi
done < "$FILE"
if [ "$FOUND" -eq 0 ]; then
echo "$LINE" >> "$FILE"
echo "Zeile hinzugefügt."
else
echo "Zeile ist bereits vorhanden."
fi
fi