-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpen_Source_Updater.clle
More file actions
82 lines (62 loc) · 4.14 KB
/
Open_Source_Updater.clle
File metadata and controls
82 lines (62 loc) · 4.14 KB
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
/********************************************************************/
/* Automate OSS Package Updates */
/* */
/* Andy Youens */
/* */
/* © 1990 - 2020 FormaServe Systems Ltd */
/* */
/* Publish in PowerWire in March 2019 */
/* */
/* Article can be found at */
/* https://powerwire.eu/open-source-updates */
/* */
/********************************************************************/
Start: Pgm
Dcl &Date *char 6
Dcl &Mbr *char 10
Dcl &IFSDir *Char 256 Value( '/oss/logs/' )
Dcl &Time *Char 6
Dcl &FullName *Char 256
Dcl &PDFName *Char 640
Dcl &MsgId *Char 7
Dcl &MsgDta *Char 256
Dcl &MsgF *Char 10
Dcl &MsgfLib *Char 10
Dcl &ErrorSw *Lgl
Copyright '© 1990 - 2020 FormaServe Systems Ltd.'
MonMsg Cpf0000 Exec(Goto Error)
RtvSysVal QDate &Date
RtvSysVal QTime &Time
/* Create naming convention for logging */
ChgVar &Mbr ('Log_' || &Date )
ChgVar &FullName ('/QSYS.LIB/POWERWIRE.LIB/OSS_LOG.FILE/' || &Mbr |< '.MBR')
/* Create Audit Log */
CrtPf File(PowerWire/OSS_log) RcdLen(512) TEXT('OSS Audit Log ') MaxMbrs(*Nomax)
MonMsg (Cpf5813 Cpf7302) /* Aleady exists - dont care! */
/* Remove previous log */
RmvLnk '/oss/logs/yumupdates.log'
Monmsg CPFA0A9 /* Dont care if not there */
/* Check if there are any updates */
QSH Cmd('/QOpenSys/pkgs/bin/yum check-update > /oss/logs/yumupdates.log')
/* Copy log file to physical file */
Cpy Obj('/oss/logs/yumupdates.log') ToObj(&fullname) Replace(*Yes) DtaFmt(*Text)
/* Produce spool of packages to be updated */
CpyF FromFile(PowerWire/OSS_Log) ToFile(*LIBL/QSYSPRT) FromMbr(&Mbr)
/* Build PDF name - Uses Date & Time to make unique */
ChgVar &PdfName (&IFSDir |< 'Yum Update Log ' || &Date || '_' || &Time |< '.pdf')
/* Create PDF for auditing purposes */
CpySplF File(QSYSPRT) ToFile(*ToStmf) Job(*) SplNbr(*Last) ToStmf(&PdfName) Wscst(*Pdf) +
StmfOpt(*Replace)
/* Update packages */
QSH Cmd('/QOpenSys/pkgs/bin/yum update < /tmp/yes >> /tmp/os002')
/* All Done - 'Omers! */
Return
Error: If Cond(&ErrorSw) Then(SndPgmMsg MsgID(Cpf9999) MsgF(QCpfMsg) MsgType(*Escape))
ChgVar &ErrorSw '1'
Error2: RcvMsg MsgType(*Diag) MsgDta(&MsgDta) MsgID(&MsgID) MsgF(&MsgF) SndMsgFLib(&MsgFLib)
If (&MsgID = ' ') Goto Error3
SndPgmMsg MsgID(&MsgID) MsgF(&MsgFLib/&Msgf) MsgDta(&MsgDta) MsgType(*Diag)
Goto Error2
Error3: RcvMsg MsgType(*Excp) MsgDta(&MsgDta) MsgID(&MsgID) MsgF(&MsgF) SndMsgFLib(&MsgFLib)
SndPgmMsg MsgID(&MsgID) MsgF(&MsgFLib/&MsgF) MsgDta(&MsgDta) MsgType(*Escape)
End: EndPgm