38 lines
1.2 KiB
Bash
38 lines
1.2 KiB
Bash
#!/bin/sh
|
|
|
|
# Source and destination directories
|
|
SRC_DIR="/mnt/place-config/etc/nginx/sites-available"
|
|
SITES_AVAILABLE="/etc/nginx/sites-available"
|
|
SITES_ENABLED="/etc/nginx/sites-enabled"
|
|
|
|
# Check if source directory exists
|
|
if [ ! -d "$SRC_DIR" ]; then
|
|
echo "Error: Source directory $SRC_DIR does not exist!"
|
|
exit 1
|
|
fi
|
|
|
|
# Create destination directories if they don't exist
|
|
mkdir -p "$SITES_AVAILABLE"
|
|
mkdir -p "$SITES_ENABLED"
|
|
|
|
# Copy all .conf files from source to sites-available
|
|
echo "Copying .conf files from $SRC_DIR to $SITES_AVAILABLE..."
|
|
cp -v "$SRC_DIR"/*.conf "$SITES_AVAILABLE/"
|
|
|
|
# Create symbolic links in sites-enabled
|
|
echo "Creating symbolic links in $SITES_ENABLED..."
|
|
for config_file in "$SITES_AVAILABLE"/*.conf; do
|
|
if [ -f "$config_file" ]; then
|
|
filename=$(basename "$config_file")
|
|
# Remove existing link/file if it exists
|
|
if [ -e "$SITES_ENABLED/$filename" ] || [ -L "$SITES_ENABLED/$filename" ]; then
|
|
rm -f "$SITES_ENABLED/$filename"
|
|
fi
|
|
# Create symbolic link
|
|
ln -sf "$config_file" "$SITES_ENABLED/$filename"
|
|
echo "Linked: $SITES_ENABLED/$filename -> $config_file"
|
|
fi
|
|
done
|
|
|
|
echo "Operation completed successfully!"
|