From d96a54789c59464a3e327cd27494b9582c3c2f12 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Sat, 26 Sep 2020 14:51:09 +0300 Subject: [PATCH] Improve cookbook --- COOKBOOK.md | 192 +++++++++++++++++++++++++++------------------------- 1 file changed, 98 insertions(+), 94 deletions(-) diff --git a/COOKBOOK.md b/COOKBOOK.md index e100237a..d33d6071 100644 --- a/COOKBOOK.md +++ b/COOKBOOK.md @@ -100,7 +100,7 @@ dir "/home/john" ``` -
+ ### Global @@ -121,7 +121,7 @@ pkg php nginx libhttp2 libhttp2-devel ``` -
+ #### `unsafe-actions` @@ -140,7 +140,7 @@ unsafe-actions yes ``` -
+ #### `require-root` @@ -161,7 +161,7 @@ require-root yes ``` -
+ #### `fast-finish` @@ -180,7 +180,7 @@ fast-finish yes ``` -
+ #### `lock-workdir` @@ -199,7 +199,7 @@ lock-workdir no ``` -
+ #### `unbuffer` @@ -218,7 +218,7 @@ unbuffer yes ``` -
+ #### `delay` @@ -237,7 +237,7 @@ delay 1.5 ``` -
+ #### `command` @@ -284,7 +284,7 @@ command:init "my app initdb" "Init database" ``` -
+ ### Variables @@ -324,7 +324,7 @@ command "service start {service}" "Starting service" ``` -
+ ### Actions @@ -361,7 +361,7 @@ command "git clone git@github.com:user/repo.git" "Repository clone" ``` -
+ ##### `wait` @@ -383,7 +383,7 @@ command "echo 'ABCD'" "Simple echo command" ``` -
+ #### Input/Output @@ -418,7 +418,7 @@ command "echo 'ABCD'" "Simple echo command with 1 seconds timeout" ``` -
+ ##### `expect-stdout` @@ -441,7 +441,7 @@ command "myApp 1" "Simple command" ``` -
+ ##### `expect-stderr` @@ -464,7 +464,7 @@ command "myApp ABCD" "Simple command" ``` -
+ ##### `print` @@ -486,7 +486,7 @@ command "echo 'ABCD'" "Simple echo command" ``` -
+ ##### `wait-output` @@ -528,7 +528,7 @@ command "echo 'ABCD'" "Simple echo command" ``` -
+ ##### `output-contains` @@ -550,7 +550,7 @@ command "echo 'ABCD'" "Simple echo command" ``` -
+ ##### `output-trim` @@ -568,7 +568,7 @@ command "echo 'ABCD'" "Simple echo command" ``` -
+ #### Filesystem @@ -595,7 +595,7 @@ command "-" "Check environment" ``` -
+ ##### `mode` @@ -618,7 +618,7 @@ command "-" "Check environment" ``` -
+ ##### `owner` @@ -644,7 +644,7 @@ command "-" "Check environment" ``` -
+ ##### `exist` @@ -666,7 +666,7 @@ command "-" "Check environment" ``` -
+ ##### `readable` @@ -689,7 +689,7 @@ command "-" "Check environment" ``` -
+ ##### `writable` @@ -712,7 +712,7 @@ command "-" "Check environment" ``` -
+ ##### `executable` @@ -735,7 +735,7 @@ command "-" "Check environment" ``` -
+ ##### `dir` @@ -757,7 +757,7 @@ command "-" "Check environment" ``` -
+ ##### `empty` @@ -779,7 +779,7 @@ command "-" "Check environment" ``` -
+ ##### `empty-dir` @@ -801,7 +801,7 @@ command "-" "Check environment" ``` -
+ ##### `checksum` @@ -824,7 +824,7 @@ command "-" "Check environment" ``` -
+ ##### `checksum-read` @@ -847,7 +847,7 @@ command "-" "Check environment" ``` -
+ ##### `file-contains` @@ -870,7 +870,7 @@ command "-" "Check environment" ``` -
+ ##### `copy` @@ -893,7 +893,7 @@ command "-" "Check environment" ``` -
+ ##### `move` @@ -916,7 +916,7 @@ command "-" "Check environment" ``` -
+ ##### `touch` @@ -938,7 +938,7 @@ command "-" "Check environment" ``` -
+ ##### `mkdir` @@ -960,7 +960,7 @@ command "-" "Check environment" ``` -
+ ##### `remove` @@ -984,7 +984,7 @@ command "-" "Check environment" ``` -
+ ##### `chmod` @@ -1007,7 +1007,7 @@ command "-" "Check environment" ``` -
+ ##### `backup` @@ -1029,7 +1029,7 @@ command "-" "Configure environment" ``` -
+ ##### `backup-restore` @@ -1052,7 +1052,7 @@ command "-" "Configure environment" ``` -
+ #### System @@ -1076,7 +1076,7 @@ command "-" "Check environment" ``` -
+ ##### `wait-pid` @@ -1105,7 +1105,7 @@ command "-" "Check environment" ``` -
+ ##### `wait-fs` @@ -1134,7 +1134,7 @@ command "service myapp start" "Starting MyApp" ``` -
+ ##### `connect` @@ -1159,7 +1159,7 @@ command "-" "Check environment" ``` -
+ ##### `app` @@ -1181,7 +1181,7 @@ command "-" "Check environment" ``` -
+ ##### `signal` @@ -1218,7 +1218,7 @@ command "myapp --daemon" "Check my app" ``` -
+ ##### `env` @@ -1241,7 +1241,7 @@ command "-" "Check environment" ``` -
+ ##### `env-set` @@ -1264,7 +1264,7 @@ command "-" "Prepare environment" ``` -
+ #### Users/Groups @@ -1288,7 +1288,7 @@ command "-" "Check environment" ``` -
+ ##### `user-id` @@ -1311,7 +1311,7 @@ command "-" "Check environment" ``` -
+ ##### `user-gid` @@ -1334,7 +1334,7 @@ command "-" "Check environment" ``` -
+ ##### `user-group` @@ -1357,7 +1357,7 @@ command "-" "Check environment" ``` -
+ ##### `user-shell` @@ -1380,7 +1380,7 @@ command "-" "Check environment" ``` -
+ ##### `user-home` @@ -1403,7 +1403,7 @@ command "-" "Check environment" ``` -
+ ##### `group-exist` @@ -1425,7 +1425,7 @@ command "-" "Check environment" ``` -
+ ##### `group-id` @@ -1448,7 +1448,7 @@ command "-" "Check environment" ``` -
+ #### Services @@ -1472,7 +1472,7 @@ command "-" "Check environment" ``` -
+ ##### `service-enabled` @@ -1494,7 +1494,7 @@ command "-" "Check environment" ``` -
+ ##### `service-works` @@ -1516,7 +1516,7 @@ command "-" "Check environment" ``` -
+ #### HTTP @@ -1549,7 +1549,7 @@ command "-" "Make HTTP request" ``` -
+ ##### `http-header` @@ -1581,7 +1581,7 @@ command "-" "Make HTTP request" ``` -
+ ##### `http-contains` @@ -1606,7 +1606,7 @@ command "-" "Make HTTP request" ``` -
+ ##### `http-json` @@ -1631,7 +1631,7 @@ command "-" "Make HTTP request and check domain info" ``` -
+ ##### `http-set-auth` @@ -1660,7 +1660,7 @@ command "-" "Make HTTP request without auth" ``` -
+ ##### `http-set-header` @@ -1686,7 +1686,7 @@ command "-" "Make HTTP request" ``` -
+ #### Libraries @@ -1710,7 +1710,7 @@ command "-" "Check environment" ``` -
+ ##### `lib-header` @@ -1732,7 +1732,7 @@ command "-" "Check environment" ``` -
+ ##### `lib-config` @@ -1754,7 +1754,7 @@ command "-" "Check environment" ``` -
+ ##### `lib-exist` @@ -1777,7 +1777,7 @@ command "-" "Check environment" ``` -
+ ##### `lib-linked` @@ -1800,7 +1800,7 @@ command "-" "Check environment" ``` -
+ #### Python @@ -1824,7 +1824,7 @@ command "-" "Check Python module loading" ``` -
+ ##### `python3-module` @@ -1846,54 +1846,58 @@ command "-" "Check Python 3 module loading" ``` -
+ ## Examples ```yang -# Simple recipe for mkcryptpasswd utility +# Bibop recipe for MkCryptPasswd -command "mkcryptpasswd" "Generate basic hash for password" - expect "Please enter password" - print "MyPassword1234" +pkg mkcryptpasswd + +fast-finish yes + +var password MyPassword1234 +var salt SALT1234 +var salt_length 9 + +command "mkcryptpasswd -s" "Generate basic hash for password" + expect "Please enter password:" + print "{password}" expect "Hash: " exit 0 -command "mkcryptpasswd -sa SALT1234" "Generate hash for password with predefined salt" +command "mkcryptpasswd -s -sa {salt}" "Generate hash for password with predefined salt" expect "Please enter password" - print "MyPassword1234" - wait 1 - output-contains "$6$SALT1234$lTxNu4.6r/j81sirgJ.s9ai8AA3tJdp67XBWLFiE10tIharVYtzRJ9eJ9YEtQsiLzVtg94GrXAYjf40pWEEg7/" + print "{password}" + expect "$6${salt}$lTxNu4.6r/j81sirgJ.s9ai8AA3tJdp67XBWLFiE10tIharVYtzRJ9eJ9YEtQsiLzVtg94GrXAYjf40pWEEg7/" exit 0 -command "mkcryptpasswd -sa SALT1234 -1" "Generate MD5 hash for password with predefined salt" +command "mkcryptpasswd -s -sa {salt} -1" "Generate MD5 hash for password with predefined salt" expect "Please enter password" - print "MyPassword1234" - wait 1 - output-contains "$1$SALT1234$zIPLJYODoLlesdP3bf95S1" + print "{password}" + expect "$1${salt}$zIPLJYODoLlesdP3bf95S1" exit 0 -command "mkcryptpasswd -sa SALT1234 -5" "Generate SHA256 hash for password with predefined salt" +command "mkcryptpasswd -s -sa {salt} -5" "Generate SHA256 hash for password with predefined salt" expect "Please enter password" - print "MyPassword1234" - wait 1 - output-contains "$5$SALT1234$HOV.9Dkp4HSDzcfizNDG7x5ST4e74zcezvCJ8BWHuK8" + print "{password}" + expect "$5${salt}$HOV.9Dkp4HSDzcfizNDG7x5ST4e74zcezvCJ8BWHuK8" exit 0 -command "mkcryptpasswd -S" "Return error if password is too weak" +command "mkcryptpasswd -s -S" "Return error if password is too weak" expect "Please enter password" print "password" expect "Password is too weak: it is based on a dictionary word" print "password" - wait 0.5 + expect "Password is too weak: it is based on a dictionary word" print "password" - wait 0.5 - exit 1 + expect "Password is too weak: it is based on a dictionary word" + !exit 0 command "mkcryptpasswd --abcd" "Return error about unsupported argument" expect "Error! You used unsupported argument --abcd. Please check command syntax." - exit 1 - + !exit 0 ```