forked from lbdyck/prompters
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdsfs-menu
executable file
·180 lines (158 loc) · 7.34 KB
/
dsfs-menu
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#!/bin/env bash
clear
VER="0.036"
#----------------------------------------------------------------#
# Name: dsfs-menu #
# #
# Purpose: A simple to use (hopefully) prompting menu for the #
# dsfs dsadm command to help the average user find #
# and use these commands. #
# #
# Dependencies: gum or less or more #
# bash is required as /bin/sh does not work with #
# gum pager but works fine for less/more #
# #
# Author/Contributors (or whom to blame for this) #
# Lionel B. Dyck ([email protected]) #
# #
# Change History (top down): #
# 2024/02/02 LBD - 0.036 Add exports for _TAG to fix display #
# 2024/02/01 LBD - 0.035 Fix createparm #
# 2024/01/30 LBD - 0.034 Add level option for dsfs maint lvl #
# 2024/01/28 LBD - 0.033 More experimentation with createparm #
# 2024/01/27 LBD - 0.032 Fix createparm quotes #
# and default SEC to PRIM if blank #
# 2024/01/25 LBD - 0.031 more cleanup #
# 2024/01/22 LBD - 0.03 add comment about more as an option #
# - improve colors and prompting #
# 2024/01/22 LBD - 0.02 add comments and generalize pager #
# 2024/01/08 LBD - 0.00 creation #
# #
#----------------------------------------------------------------#
#----------------------------------------------------------------#
# Comment and uncomment to define which pager to use for viewing #
#----------------------------------------------------------------#
PAGER="gum pager"
# PAGER="more"
# PAGER="less"
#----------------------------------------------------------------#
# Define the REDIR's and TERM to our liking #
#----------------------------------------------------------------#
export _TAG_REDIR_IN=txt
export _TAG_REDIR_OUT=txt
export _TAG_REDIR_ERR=txt
export TERM=xterm-256color
#----------------------------------------------------------------#
# Define the color for the banner #
# 5 - purple #
# 12 - blue shade #
# 33 - darker blue #
# 46 - green #
# 51 - turq shade #
#----------------------------------------------------------------#
COLOR=51
#----------------------------------------------------------------#
# Display our banner telling everyone who we are #
#----------------------------------------------------------------#
gum style \
--foreground $COLOR --border-foreground $COLOR --border double \
--align center --width 50 --margin "1 2" --padding "2 4" \
'z/OS Open Tools dsfs User Menu' $VER
#----------------------------------------------------------------#
# Define the gum env variables #
#----------------------------------------------------------------#
export GUM_INPUT_CURSOR_FOREGROUND="#$COLOR"
export GUM_INPUT_PROMPT_FOREGROUND="#$COLOR"
export GUM_INPUT_PLACEHOLDER=". . ."
export GUM_IMPORT_PROMPT="* "
SEL=$(gum choose "createparm" "fileinfo" "fsinfo" "help" "query" "configquery" "level" --header "Select DSFS Action:" \
--header.foreground="$COLOR")
case "$SEL" in
createparm)
echo "Selected" $SEL
UID=$(id -u -n)
HLQ=$(gum input --header=" HLQ to create - must be at least 2 qualifiers and the 1st must match your userid:" \
--header.foreground="11" --placeholder="Enter HLQ" )
if [[ $HLQ != *.* ]]; then
echo 'HLQ must have multiple qualifiers.'
exit 0
fi
THLQ=$(echo "$HLQ" | tr '[:lower:]' '[:upper:]')
if [[ ! "$THLQ" == "$UID"* ]]; then
echo 'HLQ does NOT match your userid as it must - try again.'
exit 0
fi
HLQ=$(echo $HLQ | tr '[:upper:]' '[:lower:]')
TYPE=$(gum choose "txt" "bin" "rec" --header "Select DSFS type:" --header.foreground="11")
DSORG=$(gum choose "PS" "PO" --header "Select dataset model type:" --header.foreground="11")
if [ "$DSORG" = "PO" ]; then
DSORG="dsorg(po) dsntype(library)"
MODEL="-pdsmodel"
elif [ "$DSORG" = "PS" ]; then
DSORG="dsorg(ps)"
MODEL="-psmodel"
fi
RECFM=$(gum choose "FB" "VB" --header "Select Record Format:" --header.foreground="11")
LRECL=$(gum input --header "Enter the LRECL for the model:" --header.foreground="11")
BLKSZ=$(gum input --header "Enter the Blocksize for the model (0):" --header.foreground="11")
if [ -z "$BLKSZ" ]; then
BLKSZ=0
fi
SPACE=$(gum choose "tracks" "cyl" --header.foreground="11" --header "Enter Allocation Type:")
PRIM=$(gum input --header.foreground="11" --header "Enter Primary Space Quantity: (1)")
if [ -z "$PRIM" ]; then
PRIM=1
fi
SEC=$(gum input --header.foreground="11" --header "Enter Secondary Space Quantity: ($PRIM)")
if [ -z "$SEC" ]; then
SEC="$PRIM"
fi
DATAC=$(gum input --width 8 --header "SMS Data Class:" --header.foreground="11")
MGMTC=$(gum input --width 8 --header "SMS Management Class:" --header.foreground="11")
STORC=$(gum input --width 8 --header "SMS Storage Class:" --header.foreground="11")
if [ -n "$DATAC" ]; then
DSORG="$DSORG dataclas("$DATAC")"
fi
if [ -n "$MGMTC" ]; then
DSORG="$DSORG mgmtclas("$MGMTC")"
fi
if [ -n "$STORC" ]; then
DSORG="$DSORG storclas("$STORC")"
fi
echo 'Generated Command:' dsadm createparm -path /dsfs/$TYPE/$HLQ $MODEL \
'"'"$DSORG recfm($RECFM) lrecl($LRECL) blksize($BLKSZ) $SPACE space($PRIM,$SEC)"'"'
PART2="$DSORG recfm($RECFM) $SPACE space($PRIM,$SEC) lrecl($LRECL) blksize($BLKSZ)"
dsadm createparm -path /dsfs/$TYPE/$HLQ $MODEL "$PART2" \
| dsadm fileinfo -path /dsfs/$TYPE/$HLQ \
| $PAGER
;;
fileinfo)
HLQ=$(gum input --header "Enter HLQ to report on" --header.foreground="11")
TYPE=$(gum choose "txt" "bin" "rec" --header "Select DSFS type:" --header "Enter the dsfs type:" \
--header.foreground="11")
dsadm fileinfo -path /dsfs/$TYPE/$HLQ | $PAGER
;;
fsinfo)
dsadm fsinfo | $PAGER
;;
help)
HELP=$(gum choose "config" "configquery" "createparm" "fileinfo" "fsinfo" "query" --header "Select DSFS command:" \
--header.foreground="11")
dsadm help -topic $HELP | $PAGER
;;
query)
QUERY=$(gum choose "compression" "dscache" "filecache" "iobydasd" "knpfs" "locking" "metacache" \
"storage" "vnodecache" "level" --no-limit --header "Select query options:" --header.foreground="11")
QUERY=$(echo $QUERY | sed 's/\b\(\w\)/ -\1/g')
dsadm query $QUERY | $PAGER
;;
configquery)
dsadm configquery -all | $PAGER
;;
level)
dsadm level | $PAGER
;;
esac
if [ -z "$SEL" ]; then
echo 'No selection....'
fi