mid-kid
8 years ago
7 changed files with 103 additions and 6 deletions
@ -0,0 +1,5 @@ |
|||
#!/bin/sh |
|||
# Tell Profile-sync-daemon to resync |
|||
if [ -x /etc/rc.d/rc.psd ]; then |
|||
/etc/rc.d/rc.psd start |
|||
fi |
@ -0,0 +1,73 @@ |
|||
#!/bin/sh |
|||
# |
|||
# /etc/rc.d/rc.psd |
|||
# |
|||
# Start/stop profile-sync-daemon. |
|||
# |
|||
# This script enables and disables profile-sync-daemon for selected users. |
|||
# You can either define users in the $USERS array, |
|||
# or have this script scan for them and save them in $USERS_CACHE. |
|||
|
|||
USERS="" |
|||
USERS_CACHE="/run/psd-users.cache" |
|||
|
|||
scan_users() { |
|||
rm -f "$USERS_CACHE" |
|||
|
|||
for user in $(getent passwd | cut -d: -f1); do |
|||
group="$(getent passwd $user | cut -d: -f4)" |
|||
home="$(getent passwd $user | cut -d: -f6)" |
|||
shell="$(getent passwd $user | cut -d: -f7)" |
|||
if [ "$group" != "0" -a "$home" -a "$home" != "/" -a "$(grep $shell /etc/shells)" ]; then |
|||
config="$(su - $user -c 'echo $XDG_CONFIG_HOME')" |
|||
[ ! "$config" ] && config="$home/.config" |
|||
if [ -f "$config/psd/psd.conf" ]; then |
|||
echo "$user" >> "$USERS_CACHE" |
|||
fi |
|||
fi |
|||
done |
|||
} |
|||
|
|||
get_users() { |
|||
# If $USERS is empty, try to create it based on what users have an existing $XDG_CONFIG_HOME/psd/psd.conf |
|||
if [ ! "$USERS" ]; then |
|||
if [ ! -f "$USERS_CACHE" ]; then |
|||
scan_users |
|||
fi |
|||
cat "$USERS_CACHE" |
|||
else |
|||
echo "$USERS" |
|||
fi |
|||
} |
|||
|
|||
start_psd() { |
|||
if [ -x /usr/bin/psd ]; then |
|||
echo "Starting/Resyncing Profile-sync-daemon..." |
|||
for user in $(get_users); do |
|||
su - $user -c 'psd resync' |
|||
done & |
|||
fi |
|||
} |
|||
|
|||
stop_psd() { |
|||
if [ -x /usr/bin/psd ]; then |
|||
echo "Stoppping Profile-sync-daemon..." |
|||
for user in $(get_users); do |
|||
su - $user -c 'psd unsync' |
|||
done |
|||
fi |
|||
} |
|||
|
|||
case "$1" in |
|||
'start') |
|||
start_psd |
|||
;; |
|||
'stop') |
|||
stop_psd |
|||
;; |
|||
'scan_users') |
|||
scan_users |
|||
;; |
|||
*) |
|||
echo "Usage: $0 start|stop|scan_users" |
|||
esac |
Loading…
Reference in new issue