Compare commits
3 Commits
71b7352d7a
...
a822e786ef
Author | SHA1 | Date |
---|---|---|
|
a822e786ef | |
|
370e5f0074 | |
|
4b1134e736 |
11
install.sh
11
install.sh
|
@ -39,10 +39,15 @@ copy_files() {
|
||||||
rm -rf /etc/systemd/user/default.target.wants/wmde-rp-sync.service
|
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
|
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-full.prf /etc
|
||||||
cp wmde-rp-config.prf /etc
|
# cp wmde-rp-config.prf /etc
|
||||||
cp wmde-rp-perm.prf /etc
|
# cp wmde-rp-perm.prf /etc
|
||||||
cp wmde-rp.conf /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() {
|
update_pam() {
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
#!/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
|
||||||
|
|
|
@ -14,28 +14,15 @@ set -x
|
||||||
|
|
||||||
#echo `who am i` > /tmp/usersync-session.txt
|
#echo `who am i` > /tmp/usersync-session.txt
|
||||||
|
|
||||||
|
. $PREFIX/wmde-rp-common.sh
|
||||||
|
|
||||||
HOMEDIR=$(getent passwd "$PAM_USER" | cut -d: -f6)
|
HOMEDIR=$(getent passwd "$PAM_USER" | cut -d: -f6)
|
||||||
SSHARGS="-o UserKnownHostsFile=$HOMEDIR/.wmdesync/known_hosts"
|
SSHARGS="-o UserKnownHostsFile=$WMDERPDIR/known_hosts -o ControlMaster=auto -o ControlPath=~/.ssh/cm-%r@%h:%p -o ControlPersist=10m"
|
||||||
|
|
||||||
. $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
|
|
||||||
|
|
||||||
. $PREFIX/wmde-rp-common.sh
|
create_wmderpdir
|
||||||
|
|
||||||
|
|
||||||
if [ -f "$PIDFILE" ]; then
|
if [ -f "$PIDFILE" ]; then
|
||||||
OLD_PID=`cat "$PIDFILE"`
|
OLD_PID=`cat "$PIDFILE"`
|
||||||
|
@ -61,7 +48,7 @@ if [ $LASTERROR -ne 0 ]; then
|
||||||
exit $LASTERROR
|
exit $LASTERROR
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo $KNOWNHOSTS > "$HOMEDIR/.wmdesync/known_hosts"
|
echo $KNOWNHOSTS > "$WMDERPDIR/known_hosts"
|
||||||
LASTERROR=$?
|
LASTERROR=$?
|
||||||
if [ $LASTERROR -ne 0 ]; then
|
if [ $LASTERROR -ne 0 ]; then
|
||||||
echo $$ > $CONFIGSYNC
|
echo $$ > $CONFIGSYNC
|
||||||
|
@ -69,6 +56,7 @@ if [ $LASTERROR -ne 0 ]; then
|
||||||
exit $LASTERROR
|
exit $LASTERROR
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# The following creates users home directory on the nfs server if not already exists
|
# The following creates users home directory on the nfs server if not already exists
|
||||||
ssh $SSHARGS $PAM_USER@$NFSSERVER /usr/bin/true
|
ssh $SSHARGS $PAM_USER@$NFSSERVER /usr/bin/true
|
||||||
LASTERROR=$?
|
LASTERROR=$?
|
||||||
|
@ -85,10 +73,11 @@ IGNORES="-ignore 'Path .wmdesync'"
|
||||||
OTHERARGS="-auto -log -prefer newer -maxerrors 500000 -fastcheck true"
|
OTHERARGS="-auto -log -prefer newer -maxerrors 500000 -fastcheck true"
|
||||||
|
|
||||||
export UNISONLOCALHOSTNAME=`hostname`
|
export UNISONLOCALHOSTNAME=`hostname`
|
||||||
export UNISON=$HOMEDIR/.wmdesync/unison-$UNISONLOCALHOSTNAME
|
export UNISON=$WMDERPDIR/unison-$UNISONLOCALHOSTNAME
|
||||||
WMDE_UNISON_PRF=/etc/wmde-rp-full.prf
|
|
||||||
WMDE_UNISON_CFG_PRF=/etc/wmde-rp-config.prf
|
#WMDE_UNISON_PRF=/etc/wmde-rp-full.prf
|
||||||
WMDE_UNISON_PERM_PRF=/etc/wmde-rp-perm.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"
|
SERVERCMD="UNISONLOCALHOSTNAME=$UNISONLOCALHOSTNAME UNISON=$UNISON unison"
|
||||||
|
|
||||||
|
@ -101,6 +90,9 @@ if [ $LASTERROR -ne 0 ]; then
|
||||||
exit $LASTERROR
|
exit $LASTERROR
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Arbeits-Directory auch auf dem SSH-Server erstellen
|
# Arbeits-Directory auch auf dem SSH-Server erstellen
|
||||||
ssh $SSHARGS $NFSSERVER "mkdir -p $UNISON"
|
ssh $SSHARGS $NFSSERVER "mkdir -p $UNISON"
|
||||||
LASTERROR=$?
|
LASTERROR=$?
|
||||||
|
@ -149,24 +141,16 @@ generate_profile() {
|
||||||
PROFILE="$UNISON/$1.prf"
|
PROFILE="$UNISON/$1.prf"
|
||||||
echo "root = $HOMEDIR" > $PROFILE
|
echo "root = $HOMEDIR" > $PROFILE
|
||||||
echo "root = ssh://$NFSSERVER/$HOMEDIR" >> $PROFILE
|
echo "root = ssh://$NFSSERVER/$HOMEDIR" >> $PROFILE
|
||||||
cat /etc/wmde-rp-$1.prf >> $PROFILE
|
echo "$2" >> $PROFILE
|
||||||
}
|
}
|
||||||
|
|
||||||
generate_profile full
|
generate_profile config "$UNISON_CONFIG_DIRS"
|
||||||
generate_profile config
|
generate_profile full "$UNISON_FULL_DIRS"
|
||||||
generate_profile perm
|
generate_profile perm "$UNISON_PERM_DIRS"
|
||||||
|
|
||||||
#cp "$WMDE_UNISON_PRF" "$UNISON/full.prf";
|
|
||||||
#cp "$WMDE_UNISON_CFG_PRF" "$UNISON/config.prf";
|
|
||||||
|
|
||||||
|
|
||||||
# Sync config
|
|
||||||
|
|
||||||
#for item in $CONFIGDIRS; do
|
yes | unison config -times -sshargs "$SSHARGS" -servercmd "$SERVERCMD" $OTHERARGS -batch #-ignore 'Path .wmde-rp'
|
||||||
# CONFIGDIRSARGS="$CONFIGDIRSARGS -path $item"
|
|
||||||
#done
|
|
||||||
|
|
||||||
yes | unison config -times -sshargs "$SSHARGS" -servercmd "$SERVERCMD" $OTHERARGS -batch -ignore 'Path .wmdesync'
|
|
||||||
|
|
||||||
echo "PUT PID INTO CONFIG_SYNC"
|
echo "PUT PID INTO CONFIG_SYNC"
|
||||||
|
|
||||||
|
@ -175,12 +159,12 @@ echo "$$" > $CONFIGSYNC
|
||||||
echo "DONE PUT PID INTO CONFIG_SYNC"
|
echo "DONE PUT PID INTO CONFIG_SYNC"
|
||||||
|
|
||||||
# Sync all
|
# Sync all
|
||||||
yes | unison full -times -sshargs "$SSHARGS" -servercmd "$SERVERCMD" $OTHERARGS -batch -ignore 'Path .wmdesync'
|
yes | unison full -times -sshargs "$SSHARGS" -servercmd "$SERVERCMD" $OTHERARGS -batch #-ignore 'Path $WMDERPDIRNAME'
|
||||||
echo "$$" > $FULLSYNC
|
echo "$$" > $FULLSYNC
|
||||||
echo "$$" > $FIRSTSYNC
|
echo "$$" > $FIRSTSYNC
|
||||||
|
|
||||||
# Sync all & repeat
|
# Sync all & repeat
|
||||||
yes | unison perm -times -sshargs "$SSHARGS" -servercmd "$SERVERCMD" $OTHERARGS -batch -ignore 'Path .wmdesync' -repeat watch+60
|
yes | unison perm -times -sshargs "$SSHARGS" -servercmd "$SERVERCMD" $OTHERARGS -batch -repeat watch+60 #-ignore 'Path $WMDERPDIRNAME' -repeat watch+60
|
||||||
|
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
66
wmde-rp.conf
66
wmde-rp.conf
|
@ -3,7 +3,7 @@ NFSSERVER=nfsserver.gs.wikimedia.de
|
||||||
NFSHOMES=/mnt/home
|
NFSHOMES=/mnt/home
|
||||||
|
|
||||||
PREFIX=/usr/local/bin/wmde
|
PREFIX=/usr/local/bin/wmde
|
||||||
SYNCPRG=osync
|
SYNCPRG=unison
|
||||||
|
|
||||||
|
|
||||||
ADMIN_USERS="admin root" # never run roaming profiles for this users
|
ADMIN_USERS="admin root" # never run roaming profiles for this users
|
||||||
|
@ -42,6 +42,64 @@ CONFIG_DIRS=" \
|
||||||
--include=.config/*** \
|
--include=.config/*** \
|
||||||
--exclude='*' \
|
--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=" \
|
FULL_DIRS=" \
|
||||||
--exclude='$WMDERPDIRNAME' \
|
--exclude='$WMDERPDIRNAME' \
|
||||||
|
@ -92,11 +150,15 @@ PERM_DIRS=" \
|
||||||
--include='.local/share/backgrounds/***' \
|
--include='.local/share/backgrounds/***' \
|
||||||
--include=.config/*** \
|
--include=.config/*** \
|
||||||
"
|
"
|
||||||
|
|
||||||
# --exclude='.osync_workdir' \
|
# --exclude='.osync_workdir' \
|
||||||
|
|
||||||
#CONFIGDIRS=".config \
|
#CONFIGDIRS=".config \
|
||||||
# .local/share/backgrounds \
|
# .local/share/backgrounds \
|
||||||
# .ssh"
|
# .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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue