-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathService_evel_Complex
83 lines (74 loc) · 2.19 KB
/
Service_evel_Complex
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
#!/bin/bash
# Check Point Service Level License Change
# Author: Brian Roy
# Check Point Software Technologies
# Update 3/2/2017
# Check if Gateway IP is valid
if echo "$1" | { IFS=. read a b c d e;
test "$a" -ge 0 && test "$a" -le 255 &&
test "$b" -ge 0 && test "$b" -le 255 &&
test "$c" -ge 0 && test "$c" -le 255 &&
test "$d" -ge 0 && test "$d" -le 255 &&
test -z "$e" \
2> /dev/null; }; then
GATEWAY=$1
echo -n "Gateway IP "; tput setaf 2; echo -n "$GATEWAY"; tput sgr0; echo " is valid"
else
2>/dev/null
BADGATEWAY=$1
tput setaf 1; echo "ERROR"; tput sgr0
echo -n "Gateway IP "; tput setaf 1; echo -n "$BADGATEWAY"; tput sgr0; echo " is not valid"
tput setaf 6; echo "Usage: ./ServiceLevel.sh X.X.X.X ServiceLevel"; tput sgr0
exit 1
fi
# Check if SERVICELEVEL is a valid selection
if [[ "$2" =~ ^(Essential|Core|Complete)$ ]]; then
SERVICELEVEL=$2
echo -n "Gateway will be set to to "; tput setaf 2; echo "$SERVICELEVEL"; tput sgr0
else
tput setaf 1; echo "ERROR"; tput sgr0
echo "Please enter one of the following (Case Sensitive)"
tput setaf 3
echo "Essential"
echo "Core"
echo "Complete"
tput setaf 6; echo "Usage: ./ServiceLevel.sh X.X.X.X ServiceLevel"; tput sgr0
exit 2
fi
#Define $CPLICPUT
if $SERVICELEVEL="Essential"; then
CPLICPUT="XXXXXXXXXX"
# Apply Core License
elif $SERVICELEVEL="Core"; then
CPLICPUT="YYYYYYYYYY"
# Apply Complete License
elif $SERVICELEVEL="Complete"; then
CPLICPUT="ZZZZZZZZZZ"
fi
# Remove Old License
if rm $CPDIR/conf/cp.license 2>/dev/null; then
echo "Old license removed successfully"
else
tput setaf 1; echo "ERROR"; tput sgr0
echo "Old license could not be removed"
exit 4
fi
# Add New License
#Remove Old License
if $CPLICPUT 2>/dev/null; then
echo "License added successfully"
else
tput setaf 1; echo "ERROR"; tput sgr0
echo "License not added"
exit 4
fi
#Verify License
if cplic put 2>/dev/null; then
echo "License Info Below:"
else
tput setaf 1; echo "ERROR"; tput sgr0
echo "No license found"
exit 6
fi
# Reset terminal colors back to defaults
tput sgr0