Skip to content

Commit

Permalink
modules: misc: Add a small helper module
Browse files Browse the repository at this point in the history
Maybe I'll collect enough small snippets that I can keep them in here
until they get split out elsewhere to more appropriate places.
  • Loading branch information
purpleidea committed Sep 26, 2024
1 parent 13fc711 commit 9a752da
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions modules/misc/main.mcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import "os"

# ssh_keygen creates an ssh key pair in the user's home directory if the private
# key doesn't exist.
# TODO: add more parameters such as key size and type in the future
class ssh_keygen($user) {
panic($user == "") # panic if $user is empty
$p = os.expand_home("~${user}/") # eg: ~james/
exec "ssh-keygen-${user}" {
cmd => "/usr/bin/ssh-keygen",
args => [
"-t", "rsa", # type
"-f", "${p}.ssh/id_rsa", # private key file
"-N", "", # empty password
],
creates => "${p}.ssh/id_rsa",
user => $user,
}
}
Empty file added modules/misc/metadata.yaml
Empty file.

0 comments on commit 9a752da

Please sign in to comment.