commit ac387aec264a333e22a3f1d71d4a2e9a048e3ccb
| author | 斟酌 鵬兄 <tgckpg@gmail.com> |
| date | 2017-09-20T05:23:07Z |
| subject | Added cyg-update scripts |
commit ac387aec264a333e22a3f1d71d4a2e9a048e3ccb
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date: 2017-09-20T05:23:07Z
Added cyg-update scripts
---
bash/cygwin/bin/cyg-import-key | 13 +++++++++++++
bash/cygwin/bin/cyg-update | 2 ++
bash/cygwin/bin/cyg-update-installer | 27 +++++++++++++++++++++++++++
3 files changed, 42 insertions(+)
diff --git a/bash/cygwin/bin/cyg-import-key b/bash/cygwin/bin/cyg-import-key
new file mode 100755
index 0000000..4c14f03
--- /dev/null
+++ b/bash/cygwin/bin/cyg-import-key
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+PUBKEY_URL="https://cygwin.com/key/pubring.asc"
+
+TMP=$( mktemp )
+
+function __o { rm $TMP; }
+trap __o EXIT
+
+
+curl "$PUBKEY_URL" > $TMP
+
+gpg2 --import $TMP
diff --git a/bash/cygwin/bin/cyg-update b/bash/cygwin/bin/cyg-update
new file mode 100755
index 0000000..c4a9cc6
--- /dev/null
+++ b/bash/cygwin/bin/cyg-update
@@ -0,0 +1,2 @@
+#!/bin/bash
+/opt/setup-x86_64.exe -qg
diff --git a/bash/cygwin/bin/cyg-update-installer b/bash/cygwin/bin/cyg-update-installer
new file mode 100755
index 0000000..9739d29
--- /dev/null
+++ b/bash/cygwin/bin/cyg-update-installer
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+SETUP_BIN="/opt/setup-x86_64.exe"
+
+SIG_URL="https://cygwin.com/setup-x86_64.exe.sig"
+SETUP_URL="https://cygwin.com/setup-x86_64.exe"
+
+TMP_BIN=$( mktemp )
+TMP_SIG=$( mktemp )
+
+function __o { rm $TMP_BIN; rm $TMP_SIG; }
+trap __o EXIT
+
+echo "Downloading Signature ..."
+curl -s "$SIG_URL" > $TMP_SIG
+echo "Downloading setup binary ..."
+curl -s "$SETUP_URL" > $TMP_BIN
+
+echo "Verifying Signature ..."
+gpg2 -q --verify $TMP_SIG $TMP_BIN
+if [ $? -ne 0 ]; then
+ echo "ERROR: Bad Signature!"
+else
+ echo "Installing setup"
+ cp $TMP_BIN $SETUP_BIN
+ chmod +x $SETUP_BIN
+fi