!!! Warning: make sure that https://github.com/gmasonPCS/rsync-on-esxi/releases/download/Release/rsync-on-esxi.zip is a safe source before installing it on your server !!!
#!/bin/sh
# Configuration
DATASTORE_NAME="datastore1"
TARGET_DIR="/vmfs/volumes/$DATASTORE_NAME/custom-bin"
RSYNC_URL="https://github.com/gmasonPCS/rsync-on-esxi/releases/download/Release/rsync-on-esxi.zip"
TMP_ZIP="/tmp/rsync-on-esxi.zip"
# Create target directory
mkdir -p "$TARGET_DIR"
# Download rsync zip
wget --no-check-certificate -O "$TMP_ZIP" "$RSYNC_URL"
# Unzip into target directory
unzip -o "$TMP_ZIP" -d "$TARGET_DIR"
# Move and set permissions
mv "$TARGET_DIR/rsync-static" "$TARGET_DIR/rsync-static.bin"
chmod 755 "$TARGET_DIR/rsync-static.bin"
# Create symlink to /bin
ln -sf "$TARGET_DIR/rsync-static.bin" /bin/rsync
# Install firewall rule
if [ -f "$TARGET_DIR/rsync.xml" ]; then
cp "$TARGET_DIR/rsync.xml" /etc/vmware/firewall/rsync.xml
esxcli network firewall refresh
fi
# Create persistent boot script
cat <<EOF > /etc/rc.local.d/local.sh
#!/bin/sh
sleep 10
RSYNC_BIN_PATH="$TARGET_DIR/rsync-static.bin"
RSYNC_XML_PATH="$TARGET_DIR/rsync.xml"
if [ -f "\$RSYNC_BIN_PATH" ]; then
ln -sf "\$RSYNC_BIN_PATH" /bin/rsync
chmod 755 "\$RSYNC_BIN_PATH"
fi
if [ -f "\$RSYNC_XML_PATH" ]; then
cp "\$RSYNC_XML_PATH" /etc/vmware/firewall/rsync.xml
esxcli network firewall refresh
fi
exit 0
EOF
# Make boot script executable
chmod +x /etc/rc.local.d/local.sh
echo "✅ rsync installed and made persistent on ESXi host"