File: tryshell.cf.sub

package info (click to toggle)
cfengine3 3.24.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 37,552 kB
  • sloc: ansic: 163,161; sh: 10,296; python: 2,950; makefile: 1,744; lex: 784; yacc: 633; perl: 211; pascal: 157; xml: 21; sed: 13
file content (78 lines) | stat: -rw-r--r-- 2,064 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#######################################################
#
# Test command useshell parameters
#
#######################################################

body common control
{
  inputs => { "../../default.cf.sub" };
  bundlesequence  => { "init", "test" };
  version => "1.0";
}

#######################################################

bundle agent init
{
  vars:
    "origtestdir" string => dirname("$(this.promise_filename)");
}

#######################################################

bundle agent test
{
  classes:
    "shelltype_noshell" or => { "useshell_noshell", "useshell_false", "useshell_no", "useshell_off" };
    "shelltype_useshell" or => { "useshell_useshell", "useshell_true", "useshell_yes", "useshell_on" };
    "shelltype_powershell" or => { "useshell_powershell" };

  vars:
    useshell_true::
      "shelltype" string => "true";
    useshell_false::
      "shelltype" string => "false";
    useshell_yes::
      "shelltype" string => "yes";
    useshell_no::
      "shelltype" string => "no";
    useshell_on::
      "shelltype" string => "on";
    useshell_off::
      "shelltype" string => "off";
    useshell_noshell::
      "shelltype" string => "noshell";
    useshell_useshell::
      "shelltype" string => "useshell";
    useshell_powershell::
      "shelltype" string => "powershell";

    shelltype_noshell.windows::
      "shellcmd" string => "c:\windows\system32\cmd.exe /C type";
    shelltype_noshell.!windows::
      "shellcmd" string => "/bin/cat";
    shelltype_useshell.windows::
      "shellcmd" string => "type";
    shelltype_useshell.!windows::
      "shellcmd" string => "cat";
    shelltype_powershell::
      "shellcmd" string => "Get-Content";

  classes:
    "shell_specified" or => { "shelltype_noshell", "shelltype_useshell", "shelltype_powershell" };

  commands:
    shell_specified::
      "$(shellcmd) $(init.origtestdir)$(const.dirsep)text.txt"
        contain => shelltype;

  reports:
    !shell_specified::
      "No shell type specified!";
}

body contain shelltype
{
  useshell => "$(test.shelltype)";
}