Skip to content

Commit

Permalink
better reset
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Pastusek authored and Dan Pastusek committed Mar 13, 2024
1 parent bcd0fa2 commit 9ba6a17
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "pibox-host",
"version": "1.40.0",
"version": "1.41.0",
"private": true,
"bin": "server.js",
"scripts": {
Expand Down
15 changes: 5 additions & 10 deletions src/pages/api/reset-setup.js
Expand Up @@ -68,14 +68,9 @@ export default async function handler(req, res) {

async function resetDrives() {
await execAndLog('GLOBAL', `umount /pibox`, { bypassError: true })
await execAndLog('GLOBAL', `lvdisplay | grep "LV Path" | awk '{print $3}' | xargs -I {} lvchange -an {}`, { bypassError: true })
await execAndLog('GLOBAL', `vgchange -an`, { bypassError: true })
await execAndLog('GLOBAL', `lvremove /dev/pibox_vg/pibox_lv -y`, { bypassError: true })
await execAndLog('GLOBAL', `vgremove pibox_vg -y`, { bypassError: true })
await execAndLog('DRIVE1', `pvremove /dev/sda -y`, { bypassError: true })
await execAndLog('DRIVE2', `pvremove /dev/sdb -y`, { bypassError: true })
await execAndLog('DRIVE1', `echo "YES" | cryptsetup erase /dev/sda`, { bypassError: true })
await execAndLog('DRIVE2', `echo "YES" | cryptsetup erase /dev/sdb`, { bypassError: true })
await execAndLog('DRIVE1', `dd if=/dev/zero of=/dev/sda bs=1M count=10`, { bypassError: true })
await execAndLog('DRIVE2', `dd if=/dev/zero of=/dev/sdb bs=1M count=10`, { bypassError: true })
await execAndLog('GLOBAL', `vgchange -an pibox_vg`, { bypassError: true })
await execAndLog('GLOBAL', `echo "YES" | cryptsetup luksClose /dev/mapper/encrypted_sda`, { bypassError: true })
await execAndLog('GLOBAL', `echo "YES" | cryptsetup luksClose /dev/mapper/encrypted_sdb`, { bypassError: true })
await execAndLog('DRIVE1', `dd if=/dev/zero of=/dev/sda bs=1M count=100`, { bypassError: true })
await execAndLog('DRIVE2', `dd if=/dev/zero of=/dev/sdb bs=1M count=100`, { bypassError: true })
}

0 comments on commit 9ba6a17

Please sign in to comment.