Skip to content

Commit e087483

Browse files
committed
v0.5.8 update
updated README bumped jsch and postgresql dependency versions build script override to generate two addons, one with a preset configuration and one without do not verify PostgreSQL host when connecting to localhost or 127.0.0.1 dynamically set version in Setup.sql improved error handling during archive resource extraction decorative improvements to front-end HTML and CSS more verbose logging when in debug mode sync only the latest cumulative update
1 parent 45b0199 commit e087483

30 files changed

+661
-220
lines changed

README.md

Lines changed: 329 additions & 2 deletions
Large diffs are not rendered by default.

config/BUILD_DETAILS

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ update-api-9.0.002
2828
webserver-api-9.0.002
2929

3030
Packaged Dependencies:
31-
jsch-0.2.17-sources
32-
jsch-0.2.17
31+
jsch-0.2.21-sources
32+
jsch-0.2.21
3333
json-20240303-sources
3434
json-20240303
35-
postgresql-42.7.3-sources
36-
postgresql-42.7.3
35+
postgresql-42.7.4-sources
36+
postgresql-42.7.4

config/EXTERNAL_DEPS

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
url:postgresql-42.7.3.jar:https://repo1.maven.org/maven2/org/postgresql/postgresql/42.7.3/postgresql-42.7.3.jar
2-
url:postgresql-42.7.3-sources.jar:https://repo1.maven.org/maven2/org/postgresql/postgresql/42.7.3/postgresql-42.7.3-sources.jar
3-
url:jsch-0.2.17.jar:https://repo1.maven.org/maven2/com/github/mwiede/jsch/0.2.17/jsch-0.2.17.jar
4-
url:jsch-0.2.17-sources.jar:https://repo1.maven.org/maven2/com/github/mwiede/jsch/0.2.17/jsch-0.2.17-sources.jar
1+
url:postgresql-42.7.4.jar:https://repo1.maven.org/maven2/org/postgresql/postgresql/42.7.4/postgresql-42.7.4.jar
2+
url:postgresql-42.7.4-sources.jar:https://repo1.maven.org/maven2/org/postgresql/postgresql/42.7.4/postgresql-42.7.4-sources.jar
3+
url:jsch-0.2.21.jar:https://repo1.maven.org/maven2/com/github/mwiede/jsch/0.2.21/jsch-0.2.21.jar
4+
url:jsch-0.2.21-sources.jar:https://repo1.maven.org/maven2/com/github/mwiede/jsch/0.2.21/jsch-0.2.21-sources.jar
55
url:json-20240303.jar:https://repo1.maven.org/maven2/org/json/json/20240303/json-20240303.jar
66
url:json-20240303-sources.jar:https://repo1.maven.org/maven2/org/json/json/20240303/json-20240303-sources.jar

ext/pack.bat

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
if /i "%*" EQU "--help" (
2+
echo PACK Packages all relevant files into newly created .addon and .jar archives.
3+
exit /b 0
4+
)
5+
if "%*" NEQ "" (
6+
echo Unexpected parameter.
7+
exit /b 1
8+
)
9+
echo Packing...
10+
rmdir /Q /S "%classes%" >nul 2>nul
11+
for /D %%i in ("%trackingClasses%\*") do robocopy /E "%%~fi" "%classes%" >nul 2>nul
12+
robocopy /E "%src%" "%classes%" /XF "*.java" >nul 2>nul
13+
copy /Y "%workspace%\LICENSE" "%root%\LICENSE" >nul 2>nul
14+
robocopy /MIR /MOVE "%lib%" "%workspace%\lib-sources" *-sources.jar >nul 2>nul
15+
"%JDKBin%\jar.exe" -c -M -f "%addonFile%" -C "%root%" .
16+
if %ERRORLEVEL% NEQ 0 (
17+
robocopy /E /MOVE "%workspace%\lib-sources" "%lib%" >nul 2>nul
18+
rmdir /Q /S "%workspace%\lib-sources" >nul 2>nul
19+
echo Packing unsuccessful.
20+
exit /b 1
21+
)
22+
del /F "%classes%\aces\webctrl\postgresql\resources\config.dat" >nul 2>nul
23+
del /F "%classes%\aces\webctrl\postgresql\resources\pgsslkey.pfx" >nul 2>nul
24+
del /F "%classes%\aces\webctrl\postgresql\resources\pgsslroot.cer" >nul 2>nul
25+
"%JDKBin%\jar.exe" -c -M -f "%workspace%\!name!-blank.addon" -C "%root%" .
26+
if %ERRORLEVEL% EQU 0 (
27+
robocopy /E /MOVE "%workspace%\lib-sources" "%lib%" >nul 2>nul
28+
rmdir /Q /S "%workspace%\lib-sources" >nul 2>nul
29+
echo Packing successful.
30+
exit /b 0
31+
) else (
32+
robocopy /E /MOVE "%workspace%\lib-sources" "%lib%" >nul 2>nul
33+
rmdir /Q /S "%workspace%\lib-sources" >nul 2>nul
34+
echo Packing unsuccessful.
35+
exit /b 1
36+
)

ext/sign.bat

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
if /i "%*" EQU "--help" (
2+
echo SIGN Signs the .addon archive.
3+
exit /b 0
4+
)
5+
if "%*" NEQ "" (
6+
echo Unexpected parameter.
7+
exit /b 1
8+
)
9+
if exist "%addonFile%" (
10+
echo Signing...
11+
"%JDKBin%\jarsigner.exe" -keystore "%keystore%" -storepass "!pass!" "%addonFile%" %alias% >nul
12+
if !ERRORLEVEL! EQU 0 (
13+
"%JDKBin%\jarsigner.exe" -keystore "%keystore%" -storepass "!pass!" "%workspace%\!name!-blank.addon" %alias% >nul
14+
if !ERRORLEVEL! EQU 0 (
15+
echo Signing successful.
16+
exit /b 0
17+
) else (
18+
echo Signing unsuccessful.
19+
exit /b 1
20+
)
21+
) else (
22+
echo Signing unsuccessful.
23+
exit /b 1
24+
)
25+
) else (
26+
echo Cannot sign because !name!.addon does not exist.
27+
exit /b 1
28+
)

resources/download_sql.png

5.83 KB
Loading

resources/postgresql_config.png

21.1 KB
Loading

resources/renew.sh

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/bin/bash
2+
3+
# Crontab example:
4+
# 47 23 1 * * /bin/bash /data/ssl/renew.sh
5+
6+
# Decsriptive name for this server
7+
name='PostgreSQL Database Server'
8+
# Keystore password
9+
password='PASSWORD'
10+
# Recipient email addresses for notifications (comma-delimited)
11+
12+
# DNS name for your SSL certificate
13+
dns='postgresql.domain.com'
14+
# Distinguished name for your SSL certificate
15+
dname="CN=$dns, OU=IT, O=Automatic Controls Equipment Systems\, Inc., L=Fenton, ST=MO, C=US"
16+
# Working directory
17+
folder='/data/ssl/certbot'
18+
# Final server certificate
19+
pem_cert='/data/ssl/ssl_cert'
20+
# Final server private key
21+
pem_key='/data/ssl/ssl_key'
22+
23+
# Function to send an email
24+
function send_email(){
25+
msmtp -t <<EOF
26+
To: $recipients
27+
Subject: $1
28+
29+
$2
30+
EOF
31+
}
32+
33+
# Create working directory
34+
sudo rm -Rf "$folder"
35+
sudo mkdir "$folder"
36+
if ! cd "$folder"; then
37+
send_email "$name SSL Renewal Failure" 'Monthly certificate renewal script failed to locate SSL directory.'
38+
exit 1
39+
fi
40+
41+
# Generate a new key
42+
if ! sudo keytool -keystore store -storepass "$password" -genkeypair -alias server -keyalg RSA -sigalg SHA256withRSA -keysize 2048 -keypass "$password" -validity 365 -ext "san=dns:$dns" -dname "$dname"; then
43+
send_email "$name SSL Renewal Failure" 'Monthly certificate renewal script failed to create a new 2048 bit RSA key-pair.'
44+
exit 1
45+
fi
46+
47+
# Generate a certificate request
48+
if ! sudo keytool -keystore store -storepass "$password" -alias server -certreq -file 'request.csr'; then
49+
send_email "$name SSL Renewal Failure" 'Monthly certificate renewal script failed to generate CSR.'
50+
exit 1
51+
fi
52+
53+
# Open HTTP and HTTPS ports
54+
sudo ufw allow 80/tcp
55+
sudo ufw allow 443/tcp
56+
57+
# Use certbot to sign the certificate request
58+
sudo certbot certonly --standalone --csr "$folder/request.csr" --logs-dir "$folder/logs"
59+
err="$?"
60+
61+
# Close HTTP and HTTPS ports
62+
sudo ufw delete allow 80/tcp
63+
sudo ufw delete allow 443/tcp
64+
65+
# Handle certbot failure
66+
if [[ "$err" != '0' ]]; then
67+
sudo rm -f 'request.csr'
68+
sudo rm -f ./*.pem
69+
send_email "$name SSL Renewal Failure" "Monthly certificate renewal script failed: certbot encountered error. Please see '$folder/logs' for more details."
70+
exit 1
71+
fi
72+
73+
# Apply changes
74+
sudo mv -f "$(find "/data/ssl/certbot" -maxdepth 1 -name '*_chain.pem' | sort -n | tail -n 1)" "$pem_cert"
75+
sudo openssl pkcs12 -in store -passin "pass:$password" -nocerts -noenc | sudo openssl rsa -out "$pem_key"
76+
sudo chown postgres:postgres "$pem_key"
77+
sudo chown postgres:postgres "$pem_cert"
78+
sudo chmod 600 "$pem_key"
79+
sudo chmod 666 "$pem_cert"
80+
sudo systemctl reload postgresql
81+
82+
# Clean files
83+
cd ..
84+
sudo rm -Rf "$folder"

resources/sftp_config.png

25.3 KB
Loading

resources/test_sftp.png

5.51 KB
Loading

resources/trend_browser.png

43.4 KB
Loading

resources/upload_client_key.png

5.7 KB
Loading

resources/upload_root_cert.png

5 KB
Loading

root/info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<extension version="1">
22
<name>PostgreSQL_Connect</name>
33
<description>Periodically synchronizes operators, add-ons, and specified trends with an external PostgreSQL database.</description>
4-
<version>0.5.6</version>
4+
<version>0.5.8</version>
55
<vendor>Automatic Controls Equipment Systems, Inc.</vendor>
66
<system-menu-provider>aces.webctrl.postgresql.web.SystemMenuEditor</system-menu-provider>
77
</extension>

root/webapp/main.css

Lines changed: 9 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ body, input, textarea, select {
1111
.c {
1212
text-align:center;
1313
}
14-
.checker {
15-
margin-right:0.5em;
16-
}
1714
.column {
1815
float:left;
1916
width:50%;
@@ -48,20 +45,6 @@ button:disabled {
4845
color:forestgreen;
4946
cursor:default;
5047
}
51-
.buttonCopy {
52-
border:1px solid white;
53-
border-radius: 8px;
54-
padding-left:6px;
55-
padding-right:6px;
56-
padding-top:1px;
57-
padding-bottom:1px;
58-
color:lightgreen;
59-
cursor:pointer;
60-
user-select: none;
61-
}
62-
.buttonCopy:hover {
63-
color:darkgoldenrod;
64-
}
6548
a {
6649
border:1px solid white;
6750
border-radius: 8px;
@@ -87,7 +70,7 @@ a:active,a.nav:active {
8770
}
8871
td, th {
8972
padding:4px;
90-
border:solid 1px white;
73+
border:solid 1px gray;
9174
}
9275
tr:nth-child(odd) {
9376
background-color:#222222;
@@ -102,58 +85,8 @@ table {
10285
border-collapse:collapse;
10386
margin:0 auto;
10487
}
105-
thead {
106-
border:solid 3px white;
107-
}
108-
tbody {
109-
border:solid 3px darkgoldenrod;
110-
}
111-
tfoot {
112-
border:solid 3px darkmagenta;
113-
}
114-
.tagYes {
115-
border-style:hidden;
116-
border-radius: 8px;
117-
display:inline-block;
118-
padding-left:6px;
119-
padding-right:6px;
120-
font-style:italic;
121-
margin:2px;
122-
background-color:green;
123-
}
124-
.tagNo {
125-
border-style:hidden;
126-
border-radius: 8px;
127-
display:inline-block;
128-
padding-left:6px;
129-
padding-right:6px;
130-
font-style:italic;
131-
margin:2px;
132-
background-color:darkred;
133-
}
134-
.tag {
135-
border-style:hidden;
136-
border-radius: 8px;
137-
display:inline-block;
138-
padding-left:6px;
139-
padding-right:6px;
140-
font-style:italic;
141-
margin:2px;
142-
user-select: none;
143-
}
144-
.popupSection {
145-
border:2px solid hotpink;
146-
border-radius: 2em;
147-
}
148-
.tagBox {
149-
border:2px solid dodgerblue;
150-
display:inline-block;
151-
padding-left:6px;
152-
padding-right:6px;
153-
margin:2px;
154-
margin-left:0.5em;
155-
background-color:midnightblue;
156-
font-style:normal;
88+
thead,tbody,tfoot {
89+
border:solid 3px gray;
15790
}
15891
.divGrouping {
15992
display:inline-block;
@@ -162,20 +95,12 @@ tfoot {
16295
margin-top:5px;
16396
margin-bottom:5px;
16497
}
165-
.triangle {
166-
width:0;
167-
height:0;
168-
margin-right:-0.5em;
169-
border-width:0.5em;
170-
border-style:solid;
171-
border-color:transparent transparent transparent gold;
172-
}
173-
.bar {
174-
position:absolute;
98+
.stickyBar {
99+
position:sticky;
175100
top:0;
176-
left:0;
177101
width:100%;
178-
height:1em;
179-
border:1px solid white;
180-
background-color:darkgray;
102+
background-color:black;
103+
padding-top:0.75em;
104+
border-bottom:1px solid gray;
105+
border-top:1px solid gray;
181106
}

src/aces/webctrl/postgresql/core/Config.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public static void reset(){
3232
Sync.versionCompatible = false;
3333
Sync.started = false;
3434
}
35+
Initializer.log("Server ID has been reset.");
3536
}
3637
public static void init(Path file){
3738
Config.file = file;
@@ -108,6 +109,9 @@ public static boolean save(){
108109
}
109110
}
110111
}
112+
if (Initializer.debug()){
113+
Initializer.log("Data file saved.");
114+
}
111115
return true;
112116
}catch(Throwable t){
113117
Initializer.log(t);

src/aces/webctrl/postgresql/core/ConnectSFTP.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ public boolean overwriteFile(InputStream src, String dst){
7272
}
7373
@Override public void end(){}
7474
}, ChannelSftp.OVERWRITE);
75+
if (!Initializer.stop && Initializer.debug()){
76+
Initializer.log("Uploaded file: "+dst);
77+
}
7578
return !Initializer.stop;
7679
}catch(Throwable t){
7780
Initializer.log(t);
@@ -108,6 +111,9 @@ public boolean retrieveFile(String path, OutputStream out){
108111
}
109112
@Override public void end(){}
110113
});
114+
if (!Initializer.stop && Initializer.debug()){
115+
Initializer.log("Downloaded file: "+path);
116+
}
111117
return !Initializer.stop;
112118
}catch(Throwable t){
113119
Initializer.log(t);

src/aces/webctrl/postgresql/core/HelperAPI.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,7 @@ public static boolean selfUpdate(){
345345
Thread.sleep(timeout);
346346
Files.move(Initializer.tmpAddonFile, Initializer.addonsDir.resolve(Initializer.getName()+".update"), StandardCopyOption.REPLACE_EXISTING);
347347
final Path addon = Initializer.addonsDir.resolve(Initializer.AUTO_UPDATE_ADDON+".addon");
348-
Utility.extractResource("aces/webctrl/postgresql/resources/"+Initializer.AUTO_UPDATE_ADDON+".addon", addon);
349-
if (!Files.exists(addon)){
348+
if (!Utility.extractResource("aces/webctrl/postgresql/resources/"+Initializer.AUTO_UPDATE_ADDON+".addon", addon) || !Files.exists(addon)){
350349
return false;
351350
}
352351
Thread.sleep(timeout);

0 commit comments

Comments
 (0)