OpenSolaris rsync install script
Posted by 4Aiur on 12/21/2010 in OpenSolaris | ∞
OpenSolaris rsync install script
#!/bin/bash
# OpenSolaris rsync installer
# Created by 4Aiur on 2010-12-21.
# define function
check_rsync_config () {
if [ ! -d /opt/local/etc/rsync/ ]; then
mkdir -p /opt/local/etc/rsync/
fi
if [ ! -f /opt/local/etc/rsync/rsyncd.conf ]; then
cat > /opt/local/etc/rsync/rsyncd.conf /opt/local/etc/rsync/rsyncd.secrets /var/svc/manifest/network/rsync.xml
RSYNC daemon
EOF
fi
}
rotate_log () {
logadm -w rsync -s 10m -C 10 -t '/var/log/rsync.log.%Y-%m' \
-a '/usr/sbin/svcadm restart rsync' /var/log/rsync.log
}
# Main
echo "setup rsync server start"
# Check rsync package
if ! pkgin list | grep rsync >/dev/null; then
pkgin -y in rsync
fi
# Check rsync server config file
check_rsync_config
# Check rsync service config
check_svc_rsync
# Import rsync.xml
if ! svcs -a | grep net-snmp >/dev/null; then
svccfg import /var/svc/manifest/network/rsync.xml
fi
svcadm enable rsync
# Add log rotate config
rotate_log
echo "setup rsync server done"