Compare commits

..

No commits in common. "a822e786ef08b6e2ee9e214d5fcc43ff99dbc6e3" and "71b7352d7ad96c6043c36c5d91f847c5b8647ec7" have entirely different histories.

4 changed files with 43 additions and 102 deletions

View File

@ -39,15 +39,10 @@ copy_files() {
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-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() {
@ -56,7 +51,7 @@ update_pam() {
cp postlogin /etc/authselect/custom/wmde/postlogin
authselect select custom/wmde with-mkhomedir with-sudo
authselect select custom/wmde with-mkhomedir with-sudo
authselect apply-changes
}

View File

@ -1,8 +0,0 @@
#!/bin/sh
. /etc/wmde-rp.conf
if [ -d /etc/wmde-rp.conf.d ]; then
for file in /etc/wmde-rp.conf.d/*.conf; do
[ -f "$file" ] && . "$file"
done
fi

View File

@ -14,15 +14,28 @@ set -x
#echo `who am i` > /tmp/usersync-session.txt
. $PREFIX/wmde-rp-common.sh
HOMEDIR=$(getent passwd "$PAM_USER" | cut -d: -f6)
SSHARGS="-o UserKnownHostsFile=$WMDERPDIR/known_hosts -o ControlMaster=auto -o ControlPath=~/.ssh/cm-%r@%h:%p -o ControlPersist=10m"
SSHARGS="-o UserKnownHostsFile=$HOMEDIR/.wmdesync/known_hosts"
. $PREFIX/wmde-rp-common.sh
mkdir -p $HOMEDIR/.wmdesync
LASTERROR=$?
if [ $LASTERROR -ne 0 ]; then
echo $$ > $CONFIGSYNC
echo $$ > $FULLSYNC
exit $LASTERROR
fi
#LOGFILE=$HOMEDIR/.wmdesync/usersync.log
#PIDFILE=$HOMEDIR/.wmdesync/usersync.pid
#FIRSTSYNC=$HOMEDIR/.wmdesync/firstsync-done
#FULLSYNC=$HOMEDIR/.wmdesync/fullsync-done
#CONFIGSYNC=$HOMEDIR/.wmdesync/configsync-done
create_wmderpdir
. $PREFIX/wmde-rp-common.sh
if [ -f "$PIDFILE" ]; then
OLD_PID=`cat "$PIDFILE"`
@ -48,7 +61,7 @@ if [ $LASTERROR -ne 0 ]; then
exit $LASTERROR
fi
echo $KNOWNHOSTS > "$WMDERPDIR/known_hosts"
echo $KNOWNHOSTS > "$HOMEDIR/.wmdesync/known_hosts"
LASTERROR=$?
if [ $LASTERROR -ne 0 ]; then
echo $$ > $CONFIGSYNC
@ -56,7 +69,6 @@ if [ $LASTERROR -ne 0 ]; then
exit $LASTERROR
fi
# The following creates users home directory on the nfs server if not already exists
ssh $SSHARGS $PAM_USER@$NFSSERVER /usr/bin/true
LASTERROR=$?
@ -73,11 +85,10 @@ IGNORES="-ignore 'Path .wmdesync'"
OTHERARGS="-auto -log -prefer newer -maxerrors 500000 -fastcheck true"
export UNISONLOCALHOSTNAME=`hostname`
export UNISON=$WMDERPDIR/unison-$UNISONLOCALHOSTNAME
#WMDE_UNISON_PRF=/etc/wmde-rp-full.prf
#WMDE_UNISON_CFG_PRF=/etc/wmde-rp-config.prf
#WMDE_UNISON_PERM_PRF=/etc/wmde-rp-perm.prf
export UNISON=$HOMEDIR/.wmdesync/unison-$UNISONLOCALHOSTNAME
WMDE_UNISON_PRF=/etc/wmde-rp-full.prf
WMDE_UNISON_CFG_PRF=/etc/wmde-rp-config.prf
WMDE_UNISON_PERM_PRF=/etc/wmde-rp-perm.prf
SERVERCMD="UNISONLOCALHOSTNAME=$UNISONLOCALHOSTNAME UNISON=$UNISON unison"
@ -90,9 +101,6 @@ if [ $LASTERROR -ne 0 ]; then
exit $LASTERROR
fi
# Arbeits-Directory auch auf dem SSH-Server erstellen
ssh $SSHARGS $NFSSERVER "mkdir -p $UNISON"
LASTERROR=$?
@ -141,16 +149,24 @@ generate_profile() {
PROFILE="$UNISON/$1.prf"
echo "root = $HOMEDIR" > $PROFILE
echo "root = ssh://$NFSSERVER/$HOMEDIR" >> $PROFILE
echo "$2" >> $PROFILE
cat /etc/wmde-rp-$1.prf >> $PROFILE
}
generate_profile config "$UNISON_CONFIG_DIRS"
generate_profile full "$UNISON_FULL_DIRS"
generate_profile perm "$UNISON_PERM_DIRS"
generate_profile full
generate_profile config
generate_profile perm
#cp "$WMDE_UNISON_PRF" "$UNISON/full.prf";
#cp "$WMDE_UNISON_CFG_PRF" "$UNISON/config.prf";
# Sync config
yes | unison config -times -sshargs "$SSHARGS" -servercmd "$SERVERCMD" $OTHERARGS -batch #-ignore 'Path .wmde-rp'
#for item in $CONFIGDIRS; do
# CONFIGDIRSARGS="$CONFIGDIRSARGS -path $item"
#done
yes | unison config -times -sshargs "$SSHARGS" -servercmd "$SERVERCMD" $OTHERARGS -batch -ignore 'Path .wmdesync'
echo "PUT PID INTO CONFIG_SYNC"
@ -159,12 +175,12 @@ echo "$$" > $CONFIGSYNC
echo "DONE PUT PID INTO CONFIG_SYNC"
# Sync all
yes | unison full -times -sshargs "$SSHARGS" -servercmd "$SERVERCMD" $OTHERARGS -batch #-ignore 'Path $WMDERPDIRNAME'
yes | unison full -times -sshargs "$SSHARGS" -servercmd "$SERVERCMD" $OTHERARGS -batch -ignore 'Path .wmdesync'
echo "$$" > $FULLSYNC
echo "$$" > $FIRSTSYNC
# Sync all & repeat
yes | unison perm -times -sshargs "$SSHARGS" -servercmd "$SERVERCMD" $OTHERARGS -batch -repeat watch+60 #-ignore 'Path $WMDERPDIRNAME' -repeat watch+60
yes | unison perm -times -sshargs "$SSHARGS" -servercmd "$SERVERCMD" $OTHERARGS -batch -ignore 'Path .wmdesync' -repeat watch+60
exit 0

View File

@ -3,7 +3,7 @@ NFSSERVER=nfsserver.gs.wikimedia.de
NFSHOMES=/mnt/home
PREFIX=/usr/local/bin/wmde
SYNCPRG=unison
SYNCPRG=osync
ADMIN_USERS="admin root" # never run roaming profiles for this users
@ -42,64 +42,6 @@ CONFIG_DIRS=" \
--include=.config/*** \
--exclude='*' \
"
UNISON_CONFIG_DIRS=$(cat << EOF
ignore = Path $WMDERPDIRNAME
path = .config
path = .local/share/backgrounds
path = .ssh
path = .cache/keepassxc
path = .thunderbird
path = .mozilla
ignore = Path Local
ignore = Path cache
ignore = Path */cache
ignore = Path .cache
ignore = Path */.cache
ignore = Path .cache2
ignore = Path */.cache2
ignore = Name Cache
ignore = Path */Cache
ignore = Path .thunderbird/*/ImapMail
EOF
)
UNISON_FULL_DIRS=$(cat << EOF
ignore = Path $WMDERPDIRNAME
ignore = Path Local
ignore = Path cache
ignore = Path */cache
ignore = Path .cache
ignore = Path */.cache
ignore = Path .cache2
ignore = Path */.cache2
ignore = Name Cache
ignore = Path */Cache
ignore = Path .thunderbird/*/ImapMail
ignore = Path Downloads
ignore = Path VirtualBox VMs
EOF
)
UNISON_PERM_DIRS=$(cat << EOF
ignore = Path $WMDERPDIRNAME
ignore = Path Local
ignore = Path cache
ignore = Path */cache
ignore = Path .cache
ignore = Path */.cache
ignore = Path .cache2
ignore = Path */.cache2
ignore = Name Cache
ignore = Path */Cache
ignore = Path .thunderbird/*/ImapMail
ignore = Path Downloads
ignore = Path VirtualBox VMs
EOF
)
FULL_DIRS=" \
--exclude='$WMDERPDIRNAME' \
@ -150,15 +92,11 @@ PERM_DIRS=" \
--include='.local/share/backgrounds/***' \
--include=.config/*** \
"
# --exclude='.osync_workdir' \
#CONFIGDIRS=".config \
# .local/share/backgrounds \
# .ssh"
if [ -d /etc/wmde-rp.d ]; then
for file in $(ls /etc/wmde-rp.d/*.conf 2>/dev/null | sort); do
[ -f "$file" ] && . "$file"
done
fi