Shell Script

This commit is contained in:
Paul Pabr 2022-12-19 17:57:38 +01:00
parent 3bb0c78022
commit 0d5d8d3ae4
5 changed files with 569 additions and 1368 deletions

6
package-lock.json generated Normal file
View File

@ -0,0 +1,6 @@
{
"name": "sectorfileupdater",
"lockfileVersion": 2,
"requires": true,
"packages": {}
}

1874
updater/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -6,8 +6,9 @@
<link rel="stylesheet" href="index.css" />
</head>
<body>
<button id="download" class"button is-primary">Download</button>
<button id="download" class="button is-primary">Download</button>
<button id="dirs">Open</button>
<button id="script">Run Shell Script</button>
<p>Input URL</p>
<input type="text" id="urlBox" name="name" size="80">

View File

@ -1,4 +1,5 @@
const { ipcRenderer, dialog } = require('electron');
const shell = require('electron').shell;
ipcRenderer.on("download complete", (event, file) => {
console.log(file); // Full file path
@ -36,3 +37,9 @@ function openFile() {
ipcRenderer.on('folderData', (event, data) => {
console.log(data)
})
let shellBtn = document.getElementById('script');
shellBtn.addEventListener('click', (e) => {
shell.openItem("./test.sh")
});

45
updater/src/test.sh Normal file
View File

@ -0,0 +1,45 @@
#!/bin/bash
curl https://files.aero-nav.com/EDGG >> ./current_nav_page.html
grep -Po '(?<=href=")[^"]*' ./current_nav_page.html | grep "https://files.aero-nav.com/EDGG/Full_Package_*" | head -n1 > ./links.txt
if ! grep -iq $(cat links.txt | cut -c 33- | cut -d\. -f1) ./folders.txt ; then
# Cleanup
#rm -R $(head -1 ./folders.txt) # Remove old unzipped folders
#rm $(head -1 ./folders.txt).zip # Remove old zip file
rm -R ./update-package/
rm diffs.txt
mkdir ./update-package/
rm ./diffs_del.txt
rm ./diffs_ca.txt
rm ./update-package/update_to_delete.txt
IFS=''
# Create Stuff
cat links.txt | cut -c 33- | cut -d\. -f1 >> ./folders.txt
if ! [ -f $(tail -1 ./folders.txt) ]; then
curl $(cat ./links.txt) -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8' -H 'Accept-Language: en-US,en;q=0.5' -H 'Accept-Encoding: gzip, deflate, br' -H 'DNT: 1' -H 'Connection: keep-alive' -H 'Referer: http://files.aero-nav.com/' -H 'Upgrade-Insecure-Requests: 1' -H 'Sec-Fetch-Dest: document' -H 'Sec-Fetch-Mode: navigate' -H 'Sec-Fetch-Site: cross-site' -H 'Sec-Fetch-User: ?1' --output $(tail -1 ./folders.txt).zip
fi
mkdir $(tail -1 ./folders.txt)
unzip -o $(tail -1 ./folders.txt).zip -d $(tail -1 ./folders.txt)
git diff --name-only --no-index --diff-filter=ACRTUXBD $(tail -n1 ./folders.txt)/ $(tail -n2 ./folders.txt | head -n1)/ >> ./diffs_del.txt
while read p;
do
echo ${p} | cut -d'/' -f2- >> ./update-package/update_to_delete.txt
done < ./diffs_del.txt
echo ./update_to_delete.txt >> ./update-package/update_to_delete.txt
git diff --no-index $(tail -n1 ./folders.txt)/ $(tail -n2 ./folders.txt | head -n1)/ >> ./update-package/chnages.txt
# git diff --name-only --no-index $(tail -n2 ./folders.txt | head -n1)/ $(tail -n1 ./folders.txt)/ >> ./diffs.txt
git diff --name-only --no-index --diff-filter=ACMRTUXB $(tail -n2 ./folders.txt | head -n1)/ $(tail -n1 ./folders.txt)/ >> ./diffs.txt
while read p;
do
if [[ $(echo ${p} | rev | cut -d'/' -f2- | rev | cut -d'/' -f2-) == *"/"* ]];then
mkdir -p ./update-package/$(echo ${p} | rev | cut -d'/' -f2- | rev | cut -d'/' -f2-)
cp ./${p} ./update-package/$(echo ${p} | rev | cut -d'/' -f2- | rev | cut -d'/' -f2-)
else
cp ./${p} ./update-package/$(echo ${p} | rev | cut -d'/' -f1 | rev)
fi
done < ./diffs.txt
zip -r ./update-es-$(tail -1 ./folders.txt).zip ./update-package
fi