Skip to content
Snippets Groups Projects
Unverified Commit 01966cd2 authored by Massimiliano Adamo's avatar Massimiliano Adamo
Browse files

fixing self update feature

parent a92c021c
No related branches found
No related tags found
No related merge requests found
Pipeline #29564 passed
...@@ -38,7 +38,7 @@ usage() { ...@@ -38,7 +38,7 @@ usage() {
exit exit
} }
OPTS=$(getopt -o "h" --longoptions "help,os:,arch:,upx,no-upx:,version:" -- "$@") OPTS=$(getopt -o "h" --longoptions "help,os:,arch:,upx,no-upx,version:" -- "$@")
eval set -- "$OPTS" eval set -- "$OPTS"
while true; do while true; do
...@@ -106,10 +106,9 @@ run_upx() { ...@@ -106,10 +106,9 @@ run_upx() {
upx --brute "$EXECUTABLE_PATH" upx --brute "$EXECUTABLE_PATH"
} }
if [ -n $UPX ]; then if [[ "$UPX" == 'UPX' ]]; then
run_upx run_upx
cp $EXECUTABLE_PATH . elif [[ "$NOUPX" == 'NOUPX' ]]; then
elif [ -n $NOUPX ]; then
true true
else else
while true; do while true; do
...@@ -130,4 +129,6 @@ else ...@@ -130,4 +129,6 @@ else
done done
fi fi
cp $EXECUTABLE_PATH .
echo -e "\nthe binary was compiled and it is avilable as:\n - \"$EXECUTABLE_PATH\"\n" echo -e "\nthe binary was compiled and it is avilable as:\n - \"$EXECUTABLE_PATH\"\n"
...@@ -320,6 +320,12 @@ func downloadFile(filepath string, url string) (err error) { ...@@ -320,6 +320,12 @@ func downloadFile(filepath string, url string) (err error) {
return err return err
} }
// change filemode
err = os.Chmod(filepath, 0755)
if err != nil {
return err
}
return nil return nil
} }
...@@ -359,6 +365,7 @@ Usage: ...@@ -359,6 +365,7 @@ Usage:
acme-downloader -h | --help acme-downloader -h | --help
acme-downloader -v | --version acme-downloader -v | --version
acme-downloader -b | --build acme-downloader -b | --build
acme-downloader --update
Options: Options:
-h --help Show this screen -h --help Show this screen
...@@ -385,7 +392,7 @@ Options: ...@@ -385,7 +392,7 @@ Options:
appExit(0) appExit(0)
} }
if arguments["--wildcard"] == true { if arguments["--update"] == true {
ArtifactoryBase := "https://artifactory.software.geant.org/artifactory/acme-downloader" ArtifactoryBase := "https://artifactory.software.geant.org/artifactory/acme-downloader"
ArtifactName := fmt.Sprintf("acme-downloader_%v_%v", runtime.GOOS, runtime.GOARCH) ArtifactName := fmt.Sprintf("acme-downloader_%v_%v", runtime.GOOS, runtime.GOARCH)
ToolName := os.Args[0] ToolName := os.Args[0]
...@@ -393,8 +400,18 @@ Options: ...@@ -393,8 +400,18 @@ Options:
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
ArtifactURL = fmt.Sprintf("%v/%v.exe", ArtifactoryBase, ArtifactName) ArtifactURL = fmt.Sprintf("%v/%v.exe", ArtifactoryBase, ArtifactName)
} }
downloadFile(ToolName, ArtifactURL) deleteErr := os.Remove(ToolName)
if deleteErr != nil {
fmt.Printf("Error deleting %v: %v!\n", ToolName, deleteErr)
appExit(2)
}
downloadErr := downloadFile(ToolName, ArtifactURL)
if downloadErr != nil {
fmt.Printf("Error downloading %v: %v!\n", ToolName, downloadErr)
appExit(2)
}
fmt.Printf("%v updated successfully!\n", ToolName) fmt.Printf("%v updated successfully!\n", ToolName)
appExit(0)
} }
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment