Compare commits

..

No commits in common. "master" and "unison-only" have entirely different histories.

15 changed files with 150 additions and 631 deletions

View File

@ -28,26 +28,20 @@ copy_files() {
#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-usersync-ssh.sh $PREFIX/
cp wmde-rp-progress.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
cp wmde-rp-usersync.service /etc/systemd/user/wmde-rp-usersync.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
rm -rf /etc/systemd/user/default.target.wants/wmde-rp-usersync.service
ln -s /etc/systemd/user/wmde-rp-usersync.service /etc/systemd/user/default.target.wants/wmde-rp-usersync.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 +50,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
}
@ -80,26 +74,6 @@ if [ "$OS" = "DEBIAN" ]; then
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

View File

@ -1,233 +0,0 @@
###### osync - Rsync based two way sync engine with fault tolerance
###### (C) 2013-2023 by Orsiris de Jong (www.netpower.fr)
[GENERAL]
CONFIG_FILE_REVISION=1.3.0
## Sync job identification
INSTANCE_ID="sync_test"
## Directories to synchronize.
## Initiator is the system osync runs on. The initiator directory must be a local path.
INITIATOR_SYNC_DIR="/home/git/osync/dir1"
## Target is the system osync synchronizes to (can be the same system as the initiator in case of local sync tasks). The target directory can be a local or remote path.
TARGET_SYNC_DIR="/home/git/osync/dir2"
#TARGET_SYNC_DIR="ssh://backupuser@yourhost.old:22//home/git/osync/dir2"
## If the target system is remote, you can specify a RSA key (please use full path). If not defined, the default ~/.ssh/id_rsa will be used. See documentation for further information.
#SSH_RSA_PRIVATE_KEY="/home/backupuser/.ssh/id_rsa"
## Alternatively, you may specify an SSH password file (less secure). Needs sshpass utility installed.
SSH_PASSWORD_FILE=""
## use the KRB5 credential cache to access SSH or rsync
KRB5=true
## When using ssh filter, you must specify a remote token matching the one setup in authorized_keys
_REMOTE_TOKEN=SomeAlphaNumericToken9
## Create sync directories if they do not exist (true/false)
CREATE_DIRS=true
## Log file location. Leaving this empty will create a logfile at /var/log/osync_version_SYNC_ID.log (or current directory if /var/log doesn't exist)
LOGFILE=""
## Generate an alert if initiator or target replicas have less free space than given value in KB. Set this to zero to skip disk space tests.
MINIMUM_SPACE=10240
## Bandwidth limit Kbytes / second. Leave 0 to disable limitation
BANDWIDTH=0
## If enabled, synchronization on remote system will be processed as superuser. See documentation for /etc/sudoers file configuration.
SUDO_EXEC=false
## Paranoia option. Don't change this unless you read the documentation.
RSYNC_EXECUTABLE=rsync
## Remote rsync executable path. Leave this empty in most cases
RSYNC_REMOTE_PATH=""
## Rsync exclude / include order (the option set here will be set first, eg: include will make include then exclude patterns)
RSYNC_PATTERN_FIRST=include
## List of files / directories to incldue / exclude from sync on both sides (see rsync patterns, wildcards work).
## Paths are relative to sync dirs. List elements are separated by a semicolon.
RSYNC_INCLUDE_PATTERN=""
RSYNC_EXCLUDE_PATTERN=""
#RSYNC_EXCLUDE_PATTERN="tmp;archives"
## Files that contains lists of files / directories to include / exclude from sync on both sides. Leave this empty if you don't want to use an exclusion file.
## This file has to be in the same directory as the config file
## Paths are relative to sync dirs. One element per line.
RSYNC_INCLUDE_FROM=""
RSYNC_EXCLUDE_FROM=""
#RSYNC_EXCLUDE_FROM="exclude.list"
## List elements separator char. You may set an alternative separator char for your directories lists above.
PATH_SEPARATOR_CHAR=";"
## By default, osync stores its state into the replica_path/.osync_workdir/state
## This behavior can be changed for initiator or slave by overriding the following with an absolute path to a statedir, ex /opt/osync_state/initiator
## If osync runs locally, initiator and target state dirs **must** be different
INITIATOR_CUSTOM_STATE_DIR=""
TARGET_CUSTOM_STATE_DIR=""
[REMOTE_OPTIONS]
## ssh compression should be used on WAN links, unless your remote connection is good enough (LAN), in which case it would slow down things
SSH_COMPRESSION=false
## Optional ssh options. Example to lower CPU usage on ssh compression, one can specify '-T -c arcfour -o Compression=no -x'
## -T = turn off pseudo-tty, -c arcfour = weakest but fasted ssh encryption (destination must accept "Ciphers arcfour" in sshd_config), -x turns off X11 forwarding
## arcfour isn't accepted on most newer systems, you may then prefer any AES encryption if processor has aes-ni hardware acceleration
## If the system does not provide hardware assisted acceleration, chacha20-poly1305@openssh.com is a good cipher to select
## See: https://wiki.csnu.org/index.php/SSH_ciphers_speed_comparison
## -o Compression=no is already handled by SSH_COMPRESSION option
## Uncomment the following line to use those optimizations, on secured links only
#SSH_OPTIONAL_ARGS="-T -c aes128-ctr -x"
#SSH_OPTIONAL_ARGS="-T -c chacha20-poly1305@openssh.com -x"
## Ignore ssh known hosts. DANGER WILL ROBINSON DANGER ! This can lead to security issues. Only enable this if you know what you're doing.
SSH_IGNORE_KNOWN_HOSTS=false
## Use a single TCP connection for all SSH calls. Will make remote sync faster, but may work less good on lossy links.
SSH_CONTROLMASTER=false
## Check for connectivity to remote host before launching remote sync task. Be sure the hosts responds to ping. Failing to ping will stop sync.
REMOTE_HOST_PING=false
## Check for internet access by pinging one or more 3rd party hosts before remote sync task. Leave empty if you don't want this check to be be performed. Failing to ping will stop sync.
## If you use this function, you should set more than one 3rd party host, and be sure you can ping them.
## Be aware some DNS like opendns redirect false hostnames. Also, this adds an extra execution time of a bit less than a minute.
REMOTE_3RD_PARTY_HOSTS="www.kernel.org www.google.com"
[MISC_OPTIONS]
## Optional arguments passed to rsync executable. The following are already managed by the program and shoul never be passed here
## -r -l -p -t -g -o -D -E - u- i- n --executability -A -X -L -K -H -8 --zz -skip-compress -checksum -bwlimit -partial -partial-dir -no-whole-file -whole-file -backup -backup-dir -suffix
## --exclude --exclude-from --include --include-from --list-only --stats
## When dealing with different filesystems for sync, or using SMB mountpoints, try adding --modify-window=2 --omit-dir-times as optional arguments.
RSYNC_OPTIONAL_ARGS=""
## Preserve basic linux permissions
PRESERVE_PERMISSIONS=true
PRESERVE_OWNER=true
PRESERVE_GROUP=true
## On MACOS X, does not work and will be ignored
PRESERVE_EXECUTABILITY=true
## Preserve ACLS. Make sure source and target FS can handle ACL. Disabled on Mac OSX.
PRESERVE_ACL=false
## Preserve Xattr. Make sure source and target FS can manage identical XATTRS. Disabled on Mac OSX. Apparently, prior to rsync v3.1.2 there are some performance caveats with transferring XATTRS.
PRESERVE_XATTR=false
## Transforms symlinks into referent files/dirs. Be careful as symlinks without referrent will break sync as if standard files could not be copied.
COPY_SYMLINKS=false
## Treat symlinked dirs as dirs. CAUTION: This also follows symlinks outside of the replica root.
KEEP_DIRLINKS=false
## Preserve hard links. Make sure source and target FS can manage hard links or you will lose them.
PRESERVE_HARDLINKS=false
## Do a full checksum on all files that have identical sizes, they are checksummed to see if they actually are identical. This can take a long time.
CHECKSUM=false
## Let RSYNC compress file transfers. Do not use this if both initator and target replicas are on local system. Also, do not use this if you already enabled SSH compression.
RSYNC_COMPRESS=true
## Maximum execution time (in seconds) for sync process. Set these values zero will disable max execution times.
## Soft exec time only generates a warning. Hard exec time will generate a warning and stop sync process.
SOFT_MAX_EXEC_TIME=7200
HARD_MAX_EXEC_TIME=10600
## Log a message every KEEP_LOGGING seconds just to know the task is still alive
KEEP_LOGGING=1801
## Minimum time (in seconds) in file monitor /daemon mode between modification detection and sync task in order to let copy operations finish.
MIN_WAIT=60
## Maximum time (in seconds) waiting in file monitor / daemon mode. After this time, sync is run.
## Use 0 to wait indefinitely.
MAX_WAIT=7200
[BACKUP_DELETE_OPTIONS]
## Log a list of conflictual files (EXPERIMENTAL)
LOG_CONFLICTS=false
## Send an email when conflictual files are found (implies LOG_CONFLICTS)
ALERT_CONFLICTS=false
## Enabling this option will keep a backup of a file on the target replica if it gets updated from the source replica. Backups will be made to .osync_workdir/backups
CONFLICT_BACKUP=true
## Keep multiple backup versions of the same file. Warning, This can be very space consuming.
CONFLICT_BACKUP_MULTIPLE=false
## Osync will clean backup files after a given number of days. Setting this to 0 will disable cleaning and keep backups forever. Warning: This can be very space consuming.
CONFLICT_BACKUP_DAYS=30
## If the same file exists on both replicas, newer version will be synced. However, if both files have the same timestamp but differ, CONFILCT_PREVALANCE sets winner replica.
CONFLICT_PREVALANCE=initiator
## On deletion propagation to the target replica, a backup of the deleted files can be kept. Deletions will be kept in .osync_workdir/deleted
SOFT_DELETE=true
## Osync will clean deleted files after a given number of days. Setting this to 0 will disable cleaning and keep deleted files forever. Warning: This can be very space consuming.
SOFT_DELETE_DAYS=30
## Optional deletion skip on replicas. Valid values are "initiator", "target", or "initiator,target"
SKIP_DELETION=
## Optional sync type. By default, osync is bidirectional. You may want to use osync as unidirectional sync in some circumstances. Valid values are "initiator2target" or "target2initiator"
SYNC_TYPE=
[RESUME_OPTIONS]
## Try to resume an aborted sync task
RESUME_SYNC=true
## Number maximum resume tries before initiating a fresh sync.
RESUME_TRY=2
## When a pidlock exists on slave replica that does not correspond to the initiator's instance-id, force pidlock removal. Be careful with this option if you have multiple initiators.
FORCE_STRANGER_LOCK_RESUME=false
## Keep partial uploads that can be resumed on next run, experimental feature
PARTIAL=false
## Use delta copy algortithm (usefull when local paths are network drives), defaults to true
DELTA_COPIES=true
[ALERT_OPTIONS]
## List of alert mails separated by spaces
## Most Unix systems (including Win10 bash) have mail support out of the box
## Just make sure that the current user has enough privileges to use mail / mutt / sendmail and that the mail system is configured to allow outgoing mails
## on pfSense platform, smtp support needs to be configured in System > Advanced > Notifications
DESTINATION_MAILS="your@alert.tld"
## By default, only sync warnings / errors are sent by mail. This default behavior can be overrided here
ALWAYS_SEND_MAILS=false
## Optional change of mail body encoding (using iconv)
## By default, all mails are sent in UTF-8 format without header (because of maximum compatibility of all platforms)
## You may specify an optional encoding here (like "ISO-8859-1" or whatever iconv can handle)
MAIL_BODY_CHARSET=""
## Additional mail parameters needed for Android / Busybox / Cygwin / MSYS
## Android & Busybox use sendmail (and openssl if encryption is needed)
## MSYS & Cygwin Windows mail support relies on mailsend.exe from muquit, http://github.com/muquit/mailsend which needs to be in %PATH% environment variable
SENDER_MAIL="alert@your.system.tld"
SMTP_SERVER=smtp.your.isp.tld
SMTP_PORT=25
# encryption can be tls, ssl or none
SMTP_ENCRYPTION=none
SMTP_USER=
SMTP_PASSWORD=
[EXECUTION_HOOKS]
## Commands can will be run before and / or after sync process
LOCAL_RUN_BEFORE_CMD=""
LOCAL_RUN_AFTER_CMD=""
REMOTE_RUN_BEFORE_CMD=""
REMOTE_RUN_AFTER_CMD=""
## Max execution time of commands before they get force killed. Leave 0 if you don't wan't this to happen. Time is specified in seconds.
MAX_EXEC_TIME_PER_CMD_BEFORE=0
MAX_EXEC_TIME_PER_CMD_AFTER=0
## Stops osync execution if one of the above before commands fail
STOP_ON_CMD_ERROR=true
## Run local and remote after sync commands even on failure
RUN_AFTER_CMD_ON_ERROR=false

2
rm.sh Normal file
View File

@ -0,0 +1,2 @@
rm -f /tmp/tobias.herre.txz
rm -rf /home/tobias.herre

8
test.sh Normal file
View File

@ -0,0 +1,8 @@
CONFIGDIRS="\
-path .config \
-path .local/share/backgrounds \
-path testdir1 \
-path testdir2"
echo $CONFIGDIRS

View File

@ -1,53 +1,11 @@
#!/bin/sh
HOMEDIR=$(getent passwd "$PAM_USER" | cut -d: -f6)
WMDERPDIR="$HOMEDIR/$WMDERPDIRNAME"
LOGFILE=$WMDERPDIR/usersync.log
PIDFILE=$WMDERPDIR/usersync.pid
FIRSTSYNC=$WMDERPDIR/firstsync-done
FULLSYNC=$WMDERPDIR/fullsync-done
CONFIGSYNC=$WMDERPDIR/configsync-done
create_wmderpdir ()
{
mkdir -p $WMDERPDIR
LASTERROR=$?
if [ $LASTERROR -ne 0 ]; then
echo $$ > $CONFIGSYNC
echo $$ > $FULLSYNC
exit $LASTERROR
fi
}
create_knonw_hosts_and_nfshomedir()
{
KNOWNHOSTS=`$PREFIX/wmde-rp-generate-known-hosts.sh`
LASTERROR=$?
if [ $LASTERROR -ne 0 ]; then
echo $$ > $CONFIGSYNC
echo $$ > $FULLSYNC
exit $LASTERROR
fi
echo $KNOWNHOSTS > "$WMDERPDIR/known_hosts"
LASTERROR=$?
if [ $LASTERROR -ne 0 ]; then
echo $$ > $CONFIGSYNC
echo $$ > $FULLSYNC
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=$?
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
SMALLFILESSYNC=$HOMEDIR/.wmdesync/smallfilessync-done

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

@ -23,7 +23,7 @@ export SSHARGS="-o UserKnownHostsFile=$HOMEDIR/.wmdesync/known_hosts"
. $PREFIX/wmde-rp-common.sh
TIMEOUT=10
TIMEOUT=30
echo "WAIT_FOR_FULLSYNC=$WAIT_FOR_FULLSYNC" >> /tmp/wtforsyc.txt
echo "WAIT_FOR_CONFIGC=$WAIT_FOR_CONFIG" >> /tmp/wtforsyc.txt
@ -34,7 +34,6 @@ if [ "$WAIT_FOR_CONFIG" = "never" ] && [ "$WAIT_FOR_FULLSYNC" = "never" ] ; then
exit 0
fi
echo "Loading roaming profile, please be patient ..."
if [ ! -f "$FIRSTSYNC" ]; then
FIRSTRUN="first"
@ -61,13 +60,13 @@ while [ $i -lt $TIMEOUT ]; do
i=$((i + 1))
done
if [ $i -eq $TIMEOUT ]; then
echo "Roaming profile failed - timeout."
echo "NO PIDFILE - ERROR" >> /tmp/wtforsyc.txt
exit 0
exit 1
fi
echo "PID is $PID my PID $$" >> /tmp/wtforsyc.txt
echo "Loading roaming profile, please be patient ..."
wait_for_sync() {
# $1 dir to watch

View File

@ -1,128 +0,0 @@
#!/bin/sh
exec >> /tmp/mys-$USER.txt 2>&1
set -x
. /etc/wmde-rp.conf
USER=`whoami`
PAM_USER=$USER
PAM_TYPE=open_session
. $PREFIX/wmde-rp-check-pam-user.sh
. $PREFIX/wmde-rp-common.sh
SSHARGS="-o UserKnownHostsFile=$WMDERPDIR/known_hosts"
create_wmderpdir
if [ -f "$PIDFILE" ]; then
OLD_PID=`cat "$PIDFILE"`
if kill -0 "$OLD_PID" 2> /dev/null; then
echo "Usersync already running." >> $LOGFILE
exit 0
fi
fi
echo 0 > $CONFIGSYNC
echo 0 > $FULLSYNC
echo $$ > $PIDFILE
create_knonw_hosts_and_nfshomedir
replace_keys_values() {
outfile="$1"
shift
infile="$PREFIX/osync.conf.template" # Kannst du bei Bedarf ebenfalls als Parameter machen
tmpfile="$(mktemp)"
cp "$infile" "$tmpfile"
for pair in "$@"; do
key="${pair%%=*}"
value="${pair#*=}"
# Escape key für sed
escaped_key=$(printf '%s\n' "$key" | sed 's/[][|.^$*+?{}()\\]/\\&/g')
# Escape & im Value, da es in sed als Referenz auf den Match dient
escaped_value=$(printf '%s\n' "$value" | sed 's/[&]/\\&/g')
# Ersetze Zeile mit key=... durch key=value, robust gegen Slashes
sed -i "s|^$escaped_key=.*|$key=$escaped_value|" "$tmpfile"
done
mv "$tmpfile" "$outfile"
}
CONF_INC=".config;.local/share/backgrounds"
CONF_EX=".wmde-osync;.cache;*/.cache;.cache2;*/.cache2;.thunderbird/*/ImapMail/"
FULL_INC="*"
FULL_EX=".wmde-osync;.cache;*/.cache;.cache2;*/.cache2;.thunderbird/*/ImapMail/"
echo $OPTIONAL_ARGS
generate_config()
{
PROFILE="$1"
replace_keys_values $PROFILE \
"INITIATOR_SYNC_DIR=\"$HOMEDIR\""\
"TARGET_SYNC_DIR=\"ssh://$NFSSERVER/$HOMEDIR\"" \
"SSH_OPTIONAL_ARGS=\"$SSHARGS\"" \
"RSYNC_PATTERN_FIRST=include" \
"PRESERVE_OWNER=false" \
"PRESERVE_GROUP=false" \
"RSYNC_OPTIONAL_ARGS=\"$2\"" \
"RSYNC_COMPRESS=false" \
"INSTANCE_ID=\"$3\"" \
"MIN_WAIT=30" \
"MAX_WAIT=300" \
"FORCE_STRANGER_LOCK_RESUME=true" \
"LOGFILE=\"$WMDERPDIR/wmde-rp-sync.log\"" \
# "RSYNC_PATTERN_FIRST=exclude"\
# "RSYNC_INCLUDE_PATTERN=\"$2\"" \
# "RSYNC_EXCLUDE_PATTERN=\"$3\"" \
## List of files / directories to incldue / exclude from sync on both sides (see rsync patterns, wildcards work).
## Paths are relative to sync dirs. List elements are separated by a semicolon.
# "INITIATOR_CUSTOM_STATE_DIR=\"$WMDERPDIR\"" \
# "TARGET_CUSTOM_STATE_DIR=\"$WMDERPDIR"\"
# "RSYNC_INCLUDE_PATTERN=\"Pictures/***;.config/***\"" \
# "RSYNC_EXCLUDE_PATTERN=\"*\""
}
HN=`hostname -f`
CONFNAM="$HN-`echo -n "$CONFIG_DIRS" | md5sum | cut -c1-8`"
FULLNAM="$HN-`echo -n "$FULL_DIRS" | md5sum | cut -c1-8`"
PERMNAM="$HN-`echo -n "$PERM_DIRS" | md5sum | cut -c1-8`"
generate_config "$WMDERPDIR/configsync.conf" "$CONFIG_DIRS" "$CONFNAM"
generate_config "$WMDERPDIR/fullsync.conf" "$FULL_DIRS" "$FULLNAM"
generate_config "$WMDERPDIR/permsync.conf" "$PERM_DIRS" "$PERMNAM"
osync.sh "$WMDERPDIR/configsync.conf" --verbose
echo "$$" > $CONFIGSYNC
osync.sh "$WMDERPDIR/fullsync.conf" --verbose
echo "$$" > $FULLSYNC
echo "$$" > $FIRSTSYNC
osync.sh "$WMDERPDIR/permsync.conf" --verbose --on-changes

11
wmde-rp-progress.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
while true; do
size=$(du -sh $1 | cut -f1)
echo "Loading roaming profile: $size of $2."
sleep 3
done

11
wmde-rp-start-usersync.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
echo "hallo" >> /tmp/tobias
sleep 60
echo "sart hallo" >> /tmp/tobias
systemctl --user daemon-reload
systemctl --user enable wmde-rp-usersync-nfs.service
systemctl --user start wmde-rp-usersync-nfs.service
echo "end hallo" >> /tmp/tobias

View File

@ -0,0 +1,47 @@
#!/bin/sh
. /etc/wmde-rp.conf
KNOWNHOSTS=`$PREFIX/wmde-rp-generate-known-hosts.sh`
LASTERROR=$? if [ $LASTERROR -ne 0 ]; then exit $LASTERROR fi
mkdir -p $HOMEDIR/.wmdesync
LASTERROR=$? if [ $LASTERROR -ne 0 ]; then exit $LASTERROR fi
echo $KNOWNHOSTS > "$HOMEDIR/.wmdesync/known_hosts"
LASTERROR=$? if [ $LASTERROR -ne 0 ]; then exit $LASTERROR fi
ssh $SSHARGS $PAM_USER@$NFSSERVER /usr/bin/true
LASTERROR=$? if [ $LASTERROR -ne 0 ]; then exit $LASTERROR fi
ls $NFSHOMES/$PAM_USER/
#mkdir -p $HOMEDIR/.config
#mkdir -p $NFSHOMES/$PAM_USER/.config
#unison $HOMEDIR/.config $NFSHOMES/$PAM_USER/.config $WMDE_UNISONARGS -ignore "Path .unison-wmde"
#mkdir -p $HOMEDIR/.local/share/backgrounds
#mkdir -p $NFSHOMES/$PAM_USER/.local/share/backgrounds
#unison $HOMEDIR/.local/share/backgrounds $NFSHOMES/$PAM_USER/.local/share/backgrounds $WMDE_UNISONARGS -ignore "Path .unison-wmde"
IGNORES="-ignore 'Path .wmdesync' "
OTHERARGS="-auto -log -prefer newer -fastcheck true -maxerrors 5000 "
export UNISON=$HOMEDIR/.wmdesync/unison
export UNISONLOCALHOSTNAME=`hostname`
mkdir -p $UNISON
WMDE_UNISON_PRF=/etc/wmde-rp-unison.prf
if [ -e "$WMDE_UNISON_PRF" ]; then cp "$WMDE_UNISON_PRF" "$UNISON/default.prf"; fi
echo "Doing initial profile sync, be patient ..."
eval unison $HOMEDIR $NFSHOMES/$PAM_USER $OTHERARGS -batch $IGNORES > /tmp/login.txt 2>&1
echo "Profile is now ready."

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=$WMDERPDIR/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,10 @@ 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 +72,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 +88,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 +104,6 @@ if [ $LASTERROR -ne 0 ]; then
exit $LASTERROR
fi
# Arbeits-Directory auch auf dem SSH-Server erstellen
ssh $SSHARGS $NFSSERVER "mkdir -p $UNISON"
LASTERROR=$?
@ -104,11 +115,6 @@ fi
# Lokal und remote eine Liste aller Unison-Archive erstellen
REMOTEDIR="$UNISON"
LOCALDIR="$UNISON"
# Lokal und remote eventuell vorhandene Lock- oder Cache-Dateien von Unison entfernen
rm -f $LOCALDIR/lk*
rm -f $LOCALDIR/fp*
@ -116,6 +122,9 @@ ssh $SSHARGS $PAM_USER@$NFSSERVER rm -f $REMOTEDIR/lk*
ssh $SSHARGS $PAM_USER@$NFSSERVER rm -f $REMOTEDIR/fp*
# Lokal und remote eine Liste aller Unison-Archive erstellen
REMOTEDIR="$UNISON"
LOCALDIR="$UNISON"
REMOTEFILES=$(ssh $SSHARGS $PAM_USER@$NFSSERVER find "$REMOTEDIR" -maxdepth 1 -type f -name 'ar*' -printf '%f\\n' | sort)
LOCALFILES=$(find "$LOCALDIR" -maxdepth 1 -type f -name 'ar*' -printf '%f\n' | sort)
@ -143,16 +152,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"
@ -161,12 +178,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 @@ Description=WMDE RP User Sync
After=default.target
[Service]
ExecStart=/bin/bash -c '. /etc/wmde-rp.conf; exec $PREFIX/wmde-rp-$SYNCPRG-ssh.sh'
ExecStart=/bin/bash -c 'exec /usr/local/bin/wmde/wmde-rp-usersync-ssh.sh'
Restart=always
RestartSec=20
TimeoutStopSec=5

View File

@ -3,11 +3,12 @@ NFSSERVER=nfsserver.gs.wikimedia.de
NFSHOMES=/mnt/home
PREFIX=/usr/local/bin/wmde
SYNCPRG=unison
SYNPRG=unison
ADMIN_USERS="admin root" # never run roaming profiles for this users
MIN_USER_ID=10000 # no roaming users with id < 10000 (non-IPA-users)
RPGROUPS=wmde-rp-users
NETGROUPS="wmde-rp-general"
@ -15,152 +16,12 @@ NETGROUPS="wmde-rp-general"
WAIT_FOR_CONFIG=always # always, first or never
WAIT_FOR_FULLSYNC=never # always, first or never
WMDERPDIRNAME=".wmde-rp"
CONFIGDIRS=".config \
.local/share/backgrounds \
.ssh"
CONFIG_DIRS=" \
--exclude='$WMDERPDIRNAME' \
--exclude='Local' \
--include='*.kdbx' \
--include='.ssh/***' \
--include='.cache/' \
--include='.cache/keepassxc/***' \
--exclude='cache' \
--exclude='*/cache' \
--exclude='.cache' \
--exclude='*/.cache' \
--exclude='.cache2' \
--exclude='*/.cache2' \
--exclude='Cache' \
--exclude='*/Cache' \
--exclude='.thunderbird/*/ImapMail/' \
--include='.thunderbird/***' \
--include='.mozilla/***' \
--include='.local/' \
--include='.local/share/' \
--include='.local/share/backgrounds/***' \
--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
ignore = Name .config/chromium/Singleton*
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
ignore = Name .config/chromium/Singleton*
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
ignore = Name .config/chromium/Singleton*
EOF
)
FULL_DIRS=" \
--exclude='$WMDERPDIRNAME' \
--exclude='Local' \
--include='*.kdbx' \
--include='.ssh/***' \
--include='.cache/' \
--include='.cache/keepassxc/***' \
--exclude='cache' \
--exclude='*/cache' \
--exclude='.cache' \
--exclude='*/.cache' \
--exclude='.cache2' \
--exclude='*/.cache2' \
--exclude='Cache' \
--exclude='*/Cache' \
--exclude='.thunderbird/*/ImapMail/' \
--include='.thunderbird/***' \
--include='.mozilla/***' \
--include='.local/' \
--include='.local/share/' \
--include='.local/share/backgrounds/***' \
--include=.config/*** \
--exclude='Downloads' \
--exclude='VirtualBox VMs' \
"
PERM_DIRS=" \
--exclude='$WMDERPDIRNAME' \
--exclude='Local' \
--include='*.kdbx' \
--include='.ssh/***' \
--include='.cache/' \
--include='.cache/keepassxc/***' \
--exclude='cache' \
--exclude='*/cache' \
--exclude='.cache' \
--exclude='*/.cache' \
--exclude='.cache2' \
--exclude='*/.cache2' \
--exclude='Cache' \
--exclude='*/Cache' \
--exclude='.thunderbird/*/ImapMail/' \
--include='.thunderbird/***' \
--include='.mozilla/***' \
--include='.local/' \
--include='.local/share/' \
--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
SMALLFILESSIZE=1024
CONFIGFILESSIZE=1024