-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: nushell installer + remove command + some cleanup
- Loading branch information
1 parent
508d28b
commit 92d994f
Showing
7 changed files
with
92 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env nu | ||
let temp_folder = (mktemp -d) | ||
git clone https://github.com/tulilirockz/nuspawn.git $temp_folder | ||
try { | ||
sudo sed -i "s~./lib~/usr/libexec/nuspawn~g" $"($temp_folder)/src/nuspawn" | ||
sudo mkdir "/usr/libexec/nuspawn" | ||
sudo cp ...(glob $"($temp_folder)/src/lib/*") /usr/libexec/nuspawn | ||
sudo cp $"($temp_folder)/src/nuspawn" /usr/bin/nuspawn | ||
} catch { | ||
print "Failed installing due to permission error" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ export use fetch.nu * | |
export use prune.nu * | ||
export use config.nu * | ||
export use compose.nu * | ||
export use remove.nu * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use meta.nu [MACHINE_STORAGE_PATH, MACHINE_CONFIG_PATH] | ||
use config.nu [get_config_path] | ||
use logger.nu * | ||
|
||
# Delete an nspawn image or machine | ||
export def "main remove" [ | ||
--storage-root = $MACHINE_STORAGE_PATH # Path for machine storage | ||
--config-root = $MACHINE_CONFIG_PATH # Path for nspawn configurations | ||
--yes (-y) # Do not warn when deleting machine | ||
--full (-f) = true # Delete configuration for the machine too | ||
--type (-t): string = "tar" # Type of the machine to be deleted | ||
machine_name: string # Which machine will be deleted | ||
] -> null { | ||
if not $yes { | ||
try { | ||
ls -la $"($storage_root)/($machine_name)*" | ||
} catch { | ||
logger error "Failure displaying files to be deleted due to permission errors" | ||
return | ||
} | ||
let yesno = (input $"(ansi blue_bold)Do you wish to delete the selected image? [y/N]: (ansi reset)") | ||
|
||
match $yesno { | ||
YES|yes|Yes|Y|y => { } | ||
_ => { return } | ||
} | ||
} | ||
|
||
logger warning $"Deleting image and configurations" | ||
try { | ||
rm -fivr ...(glob $"($storage_root)/(machine_name)*") | ||
if $full { | ||
rm -fivr ...(glob $"($config_root)/($machine_name)*") | ||
} | ||
} catch { | ||
logger error "Failure deleting local storage image due to permission errors" | ||
return | ||
} | ||
} |