#!/usr/bin/env bash
set -euo pipefail
SRC="$(cd "$(dirname "$0")" && pwd)"
TARGET="${1:-/var/www/html/audiomuse-plugins}"
BASE_URL="${2:-http://mrt.muratca61.keenetic.link/audiomuse-plugins}"
sudo mkdir -p "$TARGET"
sudo cp "$SRC/murat_audio_toolkit-0.2.0.zip" "$SRC/plugin.json" "$SRC/manifest.json" "$TARGET/"
sudo sed -i "s#http://mrt.muratca61.keenetic.link/audiomuse-plugins#$BASE_URL#g" "$TARGET/plugin.json" "$TARGET/manifest.json"
sudo chown -R www-data:www-data "$TARGET"
sudo find "$TARGET" -type d -exec chmod 755 {} \;
sudo find "$TARGET" -type f -exec chmod 644 {} \;
echo "$BASE_URL/manifest.json"
