Compare commits
2 Commits
55c55a4a08
...
c56aec350d
| Author | SHA1 | Date | |
|---|---|---|---|
| c56aec350d | |||
| 956cfd7325 |
+10
-20
@@ -3,30 +3,20 @@ description: mtm-ddwipe project conventions
|
|||||||
---
|
---
|
||||||
|
|
||||||
# Project conventions
|
# Project conventions
|
||||||
- Use English throughout the project.
|
- Use English.
|
||||||
- Keep shell scripts Bash-based.
|
- Use Bash for shell scripts.
|
||||||
- Preserve the current behavior of the main script: `mtm-ddwipe` wipes block devices.
|
- Keep `mtm-ddwipe` focused on wiping block devices.
|
||||||
- Strengthen destructive-action safety checks in `mtm-ddwipe`.
|
|
||||||
- Keep `mtm-ddwipe` interactive by default.
|
- Keep `mtm-ddwipe` interactive by default.
|
||||||
- Require explicit confirmation before destructive actions.
|
- Require explicit confirmation before destructive actions.
|
||||||
|
- Validate real block devices and refuse mounted or in-use targets.
|
||||||
- Show clear device details before confirmation.
|
- Show clear device details before confirmation.
|
||||||
- Check that target devices are not mounted or in use before wiping.
|
|
||||||
- Keep user-facing messages short and clear.
|
|
||||||
- Keep error and help messages short and clear.
|
|
||||||
- Prefer minimal, focused changes that preserve intent.
|
|
||||||
- Keep `.continue/rules/project.md` aligned with project conventions and concise.
|
|
||||||
- `mtm-ddwipe` is a small Bash script with helper functions.
|
|
||||||
- Keep the host and line-number removal behavior intact for related output processing.
|
|
||||||
- `mtm-ddwipe` must print a usage line and support `-h`/`--help`.
|
|
||||||
- Validate that wipe targets are real block devices before operating on them.
|
|
||||||
- Keep short, explicit confirmation prompts before destructive operations.
|
|
||||||
- Prefer confirmation prompts that require typing the target device path or an exact safety phrase.
|
|
||||||
- Keep help text concise, usage-first, and warning-focused.
|
|
||||||
- Keep destructive safeguards strict and explicit.
|
- Keep destructive safeguards strict and explicit.
|
||||||
- If adding non-interactive support, make it an opt-in safety flag.
|
- Keep messages short and clear.
|
||||||
- Keep device identification prompts clear and specific.
|
- Keep help concise, usage-first, and warning-focused.
|
||||||
- Preserve the fallback wipe flow: secure discard, zero discard, then zero-fill with `dd`.
|
- Preserve the fallback wipe flow: secure discard, zero discard, then `dd` zero-fill.
|
||||||
- Keep timing and status output short and readable.
|
- Keep changes minimal and preserve intent.
|
||||||
|
- Keep `./continue/rules/project.md` aligned and concise.
|
||||||
|
- If non-interactive support is added, make it an opt-in safety flag.
|
||||||
|
|
||||||
# Project identity
|
# Project identity
|
||||||
- Main script: `mtm-ddwipe`
|
- Main script: `mtm-ddwipe`
|
||||||
|
|||||||
+9
-7
@@ -8,7 +8,7 @@ STARTDATESTRING=""
|
|||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
Usage: mtm-ddwipe-2 DEVICE
|
Usage: mtm-ddwipe DEVICE
|
||||||
|
|
||||||
Wipe a block device.
|
Wipe a block device.
|
||||||
|
|
||||||
@@ -58,8 +58,12 @@ check_device() {
|
|||||||
check_device_not_in_use() {
|
check_device_not_in_use() {
|
||||||
local dev="$1"
|
local dev="$1"
|
||||||
|
|
||||||
|
if findmnt -rn --target "$dev" >/dev/null 2>&1; then
|
||||||
|
die "Device is mounted: $dev"
|
||||||
|
fi
|
||||||
|
|
||||||
if lsblk -nrpo NAME,MOUNTPOINT "$dev" | awk '$2 != "" { found=1 } END { exit !found }'; then
|
if lsblk -nrpo NAME,MOUNTPOINT "$dev" | awk '$2 != "" { found=1 } END { exit !found }'; then
|
||||||
die "Device or one of its children is mounted: $dev"
|
die "Device or child is mounted: $dev"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,13 +71,11 @@ confirm_wipe() {
|
|||||||
local dev="$1"
|
local dev="$1"
|
||||||
local choice=""
|
local choice=""
|
||||||
|
|
||||||
echo "Selected device:"
|
echo "Device:"
|
||||||
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT,MODEL,SERIAL "$dev"
|
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT,MODEL,SERIAL "$dev"
|
||||||
echo ""
|
echo ""
|
||||||
echo "This will destroy data on: $dev"
|
|
||||||
echo "Type exactly: WIPE $dev"
|
echo "Type exactly: WIPE $dev"
|
||||||
echo ""
|
read -r -p "Confirm: " choice
|
||||||
read -r -p "Confirmation: " choice
|
|
||||||
[ "$choice" = "WIPE $dev" ] || die "Canceled"
|
[ "$choice" = "WIPE $dev" ] || die "Canceled"
|
||||||
echo ""
|
echo ""
|
||||||
}
|
}
|
||||||
@@ -143,7 +145,7 @@ wipe_dev() {
|
|||||||
STARTDATE=$(date +%s)
|
STARTDATE=$(date +%s)
|
||||||
STARTDATESTRING="$(date)"
|
STARTDATESTRING="$(date)"
|
||||||
|
|
||||||
log "Begin wiping device $dev"
|
log "Begin wiping: $dev"
|
||||||
echo ""
|
echo ""
|
||||||
log "Start date :"
|
log "Start date :"
|
||||||
log "$STARTDATESTRING"
|
log "$STARTDATESTRING"
|
||||||
|
|||||||
Reference in New Issue
Block a user