Files
hcie-rust-v3.05/unlock.sh
T
2026-07-09 02:59:53 +03:00

93 lines
2.5 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# unlock.sh — Crate'i geçici olarak açar, değişiklik sonrası lock.sh ile tekrar kilitle
# Kullanım: ./unlock.sh hcie-blend
# ./unlock.sh all
#GUARD_USER="hcie-guard"
#SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
#BASE_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
#Ortak grup adı
GROUP="ortak"
# Betik sudo altında çalışırsa $(whoami) root döner; gerçek işleten kullanıcı
# SUDO_USER içindedir. Yoksa mevcut shell kullanıcısıdır.
CURRENT_USER="${SUDO_USER:-$(whoami)}"
# SCRIPT_DIR: Betiğin bulunduğu dizinin tam yolu
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
#BASE_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
BASE_DIR=$SCRIPT_DIR
echo $SCRIPT_DIR
echo $BASE_DIR
LOCKED_CRATES=(
"hcie-protocol"
"hcie-color"
"hcie-blend"
"hcie-history"
"hcie-brush-engine"
"hcie-draw"
"hcie-composite"
"hcie-filter"
"hcie-selection"
"hcie-text"
"hcie-vector"
"hcie-tile"
"hcie-io"
"hcie-document"
"hcie-engine-api"
"hcie-ai"
"hcie-vision"
"hcie-fx"
"hcie-psd"
"hcie-kra"
"hcie-native"
"hcie-egui-app"
"hcie-engine-api-orig"
"hcie-qt-app"
)
unlock_crate() {
local crate="$1"
local path="$BASE_DIR/$crate"
if [ ! -d "$path" ]; then
echo "❌ Bulunamadı: $path"
return 1
fi
# Crate'in tamamını (tüm dosya ve dizinleri) açar.
# Böylece AI sadece bu crate üzerinde çalışabilir.
sudo chown -R "$CURRENT_USER:$GROUP" "$path"
sudo find "$path" -type f -exec chmod 644 {} \;
sudo find "$path" -type d -exec chmod 755 {} \;
sudo find "$path" -exec setfacl -b {} + 2>/dev/null || true
sudo find "$path" -exec setfacl -m u:"$CURRENT_USER":rwx {} + 2>/dev/null || true
# Doğrulama: gerçek kullanıcının yazma hakkı var mı?
local sample_file
sample_file=$(find "$path" -type f -print -quit)
if [ -n "$sample_file" ] && getfacl -c "$sample_file" 2>/dev/null | grep -q "user:$CURRENT_USER:rwx"; then
echo "🔓 Açıldı: $crate ($CURRENT_USER:$GROUP) — değişiklik bitince: ./lock.sh $crate"
else
echo "⚠️ Uyarı: $crate içinde $CURRENT_USER kullanıcısının yazma hakkı doğrulanamadı."
fi
}
if [ -z "$1" ]; then
echo "Kullanım: $0 <crate-adı> | all"
echo "Örnek: $0 hcie-blend"
echo " $0 all"
exit 1
fi
if [ "$1" = "all" ]; then
echo "🔓 Tüm crate'ler açılıyor..."
for crate in "${LOCKED_CRATES[@]}"; do
unlock_crate "$crate"
done
echo "✅ Tümü açıldı — değişiklikler bitince: ./lock.sh all"
else
unlock_crate "$1"
fi