Revision: 70616
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 11, 2016 01:53 by swetoast
Initial Code
#!/bin/sh SELF=$(basename $0) #uses the same name as the file UPDATE_BASE=https://gitlab.com/swe_toast/self-update/raw/master/ #dont link directly to file link to the folder UPDATE_SELF=${UPDATE_SELF:-1} self_updater () { echo "Performing self-update... Please wait..." if ! wget --quiet --output-document="$0.tmp" $UPDATE_BASE/$SELF ; then echo "Failed downloading new version!" echo "File requested: $UPDATE_BASE/$SELF" exit 1 fi OCTAL_MODE=$(stat -c '%a' $0) case ${OCTAL_MODE:--1} in -[1] ) echo "Failed: Error : OCTAL_MODE was empty"; exit 1 ;; 777|775|755 ) echo "OCTAL mode set:${OCTAL_MODE}" ;; * ) echo "Failed: Error in OCTAL_MODEs, found value=${OCTAL_MODE}" exit 1 ;; esac if ! chmod $OCTAL_MODE $0.tmp ; then echo "Error on chmod $OCTAL_MODE %0.tmp from $UPDATE_BASE/$SELF, can't continue" exit 1 fi cat > /tmp/updatescript.sh << EOF #!/bin/sh if mv "$0.tmp" "$0"; then echo "Update complete.." exec env UPDATE_SELF=0 /bin/sh "$0" rm \$0 else echo "Update failed.." fi EOF echo "Inserting update process..." exec /bin/sh /tmp/updatescript.sh; rm /tmp/updatescript.sh } check_update () { if [ ${UPDATE_SELF} -ne 0 ]; then self_updater; fi } check_update
Initial URL
Initial Description
Simple script that updates itself upon launch then lauches whatever else thats included afterwards works well in almost any linux system tested on busyboxes and Debian systems
Initial Title
Selfupdating Script
Initial Tags
Initial Language
Bash