Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 34 additions & 8 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,27 @@ set_var(){
printf '%s: %s\n' "$key" "$val" >> "$VARS"
}

# Wi-Fi değerlerini local_vars.yml'e yazmadan önce denetle / check Wi-Fi values before writing them.
# Değerler "..." içinde yazılır: " ve \ YAML'ı, {{ {% {# Ansible'ı bozar.
# Values are written inside "...": " and \ break the YAML, {{ {% {# break Ansible.
bad_chars(){
case "$1" in *\"*|*\\*|*'{{'*|*'{%'*|*'{#'*) return 0;; esac
return 1
}
check_ssid(){
local bytes; bytes=$(printf '%s' "$1" | LC_ALL=C wc -c)
[ "$bytes" -le 32 ] || { echo "En fazla 32 bayt (Türkçe harf 2 bayt) / max 32 bytes"; return 1; }
case "$1" in *[[:cntrl:]]*) echo "Kontrol karakteri olamaz / no control characters"; return 1;; esac
! bad_chars "$1" || { echo "\" \\ {{ {% {# kullanılamaz / not allowed"; return 1; }
}
# WPA2: 8-63 karakter, yalnızca İngilizce klavye karakterleri / 8-63 printable ASCII characters
check_pass(){
! printf '%s' "$1" | LC_ALL=C grep -q '[^ -~]' || { echo "Yalnızca İngilizce klavye karakterleri (ş, ğ, ı... olmaz) / ASCII only"; return 1; }
[ "${#1}" -ge 8 ] && [ "${#1}" -le 63 ] || { echo "8-63 karakter olmalı / must be 8-63 characters"; return 1; }
case "$1" in ' '*|*' ') echo "Başta ya da sonda boşluk olamaz / no leading or trailing spaces"; return 1;; esac
! bad_chars "$1" || { echo "\" \\ {{ {% {# kullanılamaz / not allowed"; return 1; }
}

# ---------------------------------------------------------------- 0. kontroller
say "Kontroller / checks"
if ! mountpoint -q /library; then
Expand Down Expand Up @@ -53,15 +74,20 @@ else
set_var "${line%%:*}" "$(echo "${line#*:}" | sed 's/^ *//')"
done < "$REPO/config/iiab-overrides.yml"

read -rp "Wi-Fi ağ adı / network name [HAS_PrepperDisk]: " SSID
SSID="${SSID:-HAS_PrepperDisk}"
while :; do
read -rsp "Wi-Fi şifresi / password (en az 8 karakter / min 8 chars): " PASS; echo
[ "${#PASS}" -ge 8 ] && break
echo "Çok kısa / too short"
read -rp "Wi-Fi ağ adı / network name [HAS_PrepperDisk]: " SSID
SSID="${SSID:-HAS_PrepperDisk}"
check_ssid "$SSID" && break
done
while :; do
IFS= read -rsp "Wi-Fi şifresi / password (8-63 karakter / chars): " PASS; echo
check_pass "$PASS" || continue
IFS= read -rsp "Tekrar / again: " PASS2; echo
[ "$PASS" = "$PASS2" ] && break
echo "Şifreler aynı değil / passwords do not match"
done
set_var host_ssid "\"${SSID//\"/}\""
set_var hostapd_password "\"${PASS//\"/}\""
set_var host_ssid "\"$SSID\""
set_var hostapd_password "\"$PASS\""
echo "Ayarlar yazıldı / settings written: $VARS"

# ---------------------------------------------------------- 2. IIAB
Expand All @@ -70,7 +96,7 @@ else
if command -v iiab >/dev/null; then
iiab
else
curl -fsSL d.iiab.io/install.txt | bash
curl -fsSL https://d.iiab.io/install.txt | bash
fi
[ -f /etc/iiab/install-flags/iiab-complete ] || die "Kurulum bitmedi / install not finished. Tekrar çalıştır / run again: sudo ./install.sh"
fi
Expand Down
13 changes: 11 additions & 2 deletions scripts/setup-ssd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,17 @@ die(){ echo "HATA / ERROR: $*" >&2; exit 1; }
[ -n "$DEV" ] || { lsblk -o NAME,SIZE,FSTYPE,LABEL,MOUNTPOINTS; die "disk belirt / give a disk, e.g. /dev/nvme0n1"; }
[ -b "$DEV" ] || die "$DEV bulunamadı / not found"

ROOTDEV=$(findmnt -no SOURCE /)
case "$ROOTDEV" in "$DEV"*) die "$DEV sistem diski / is the system disk";; esac
# Sistemin çalıştığı fiziksel diske dokunma. Pi NVMe'den açılıyorsa /dev/nvme0n1p1 de sistem diskidir.
# Never touch the physical disk the system runs from (e.g. /dev/nvme0n1p1 when booting from NVMe).
disk_of(){
local d="$1" p
p=$(lsblk -ndo PKNAME "$d" 2>/dev/null) || return 1
while [ -n "$p" ]; do d="/dev/$p"; p=$(lsblk -ndo PKNAME "$d" 2>/dev/null) || return 1; done
basename "$d"
}
ROOTDISK=$(disk_of "$(findmnt -no SOURCE /)") || die "sistem diski bulunamadı / could not find the system disk"
DEVDISK=$(disk_of "$DEV") || die "$DEV okunamadı / could not read $DEV"
[ "$DEVDISK" != "$ROOTDISK" ] || die "$DEV sistem diskinde ($ROOTDISK) / is on the system disk"

if mountpoint -q "$MP" && [ "$(findmnt -no SOURCE "$MP")" = "$DEV" ]; then
echo "$DEV zaten $MP altında bağlı / already mounted at $MP"; exit 0
Expand Down