/usr/sbin/update-openrocket is in openrocket 13.11.1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | #!/bin/sh
# Copyright (C) 2006-2012 Bart Martens <bartm@knars.be>
# Copyright (C) 2013 Bdale Garbee <bdale@gag.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -e
return_0() {
return 0
}
trap "return_0" 0
die_hard() {
echo "ERROR: $1" >&2
exit 1
}
[ `whoami` = "root" ] || die_hard "must be root"
show_usage() {
echo "Usage:"
echo " update-openrocket --install"
echo " update-openrocket --uninstall"
echo " update-openrocket --status"
echo "Additional options:"
echo " --verbose"
echo " --quiet"
exit 1
}
getopt_temp=`getopt -o iusfvq --long install,uninstall,status,fast,verbose,quiet -n 'update-openrocket' -- "$@"` || show_usage
eval set -- "$getopt_temp" || show_usage
ACTION=none
fast=no
verbose=no
quiet=no
while [ true ]
do
case "$1" in
-i|--install)
ACTION="--install"
shift
;;
-u|--uninstall)
ACTION="--uninstall"
shift
;;
-s|--status)
ACTION="--status"
shift
;;
-f|--fast)
fast=yes
shift
;;
-v|--verbose)
verbose=yes
shift
;;
-q|--quiet)
quiet=yes
shift
;;
--)
shift
break
;;
*)
echo "Internal error!"
exit 1
;;
esac
done
[ "$ACTION" != "none" -a $# -eq 0 ] || show_usage
[ "$quiet" != "yes" ] || verbose=no
[ "$verbose" != "yes" ] || echo "options : $getopt_temp"
UNPACKDIR=`mktemp -d /tmp/openrocket.XXXXXXXXXX` || die_hard "mktemp failed"
echo "$UNPACKDIR" | grep -q "^/tmp/openrocket\." || die_hard "paranoia"
cd "$UNPACKDIR" || die_hard "cd failed"
[ "$verbose" != "yes" ] || echo "temporary directory: $UNPACKDIR"
do_cleanup() {
[ "$verbose" != "yes" ] || echo "cleaning up temporary directory $UNPACKDIR ..."
cd /
echo "$UNPACKDIR" | grep -q "^/tmp/openrocket\." || die_hard "paranoia"
rm -rf "$UNPACKDIR"
}
die_hard_with_a_cleanup() {
return_0
do_cleanup
die_hard "$1"
}
trap "die_hard_with_a_cleanup interrupted" INT
cachedir=/var/cache/openrocket
wgetquiet=' -q '
wgetfast='-t 3 -T 15 '
wgetalways=' -nd -P . '
wgetprogress=' -v --progress=dot:default '
get_installed_version() {
installed=`unzip -p /usr/lib/openrocket/*.jar ReleaseNotes | head -1 | awk '{ print $2 }'`
}
get_download_url() {
url=`wget -qO - http://openrocket.sourceforge.net | grep https | grep download | awk -F\" '{ print $4 }'`
}
get_upstream_version() {
get_download_url
upstream=`echo $url | awk -F/ '{ print $8 }'`
}
case "$ACTION" in
--install)
[ "$verbose" != "yes" ] || echo "selected action = $ACTION"
get_installed_version
[ "$verbose" != "yes" ] || echo "installed version = $installed"
get_upstream_version
[ "$verbose" != "yes" ] || echo "upstream version = $upstream"
if [ "$installed" != "" -a "$upstream" != "" -a "$installed" = "$upstream" ]
then
[ "$verbose" != "yes" ] || echo "upstream version $upstream is already installed"
else
wgetoptions="$wgetquiet $wgetalways"
[ "$verbose" != "yes" ] || wgetoptions="$wgetalways $wgetprogress"
[ "$fast" != "yes" ] || wgetoptions="$wgetoptions $wgetfast"
[ "$verbose" != "yes" ] || echo "wgetoptions=$wgetoptions"
[ "$verbose" != "yes" ] || echo "downloading $url..."
HOME=/root \
wget $wgetoptions $url \
|| die_hard_with_a_cleanup "wget failed to download $downloadurl"
targetdir=/usr/lib/openrocket
[ "$verbose" != "yes" ] || echo "removing old .jar files from $targetdir ..."
rm -f $targetdir/*.jar
[ "$verbose" != "yes" ] || echo "moving download to $targetdir ..."
mv -f download $targetdir/OpenRocket-$upstream.jar
[ "$verbose" != "yes" ] || ( get_installed_version && echo "create /usr/bin/openrocket wrapper" )
echo "#!/bin/sh" > /usr/bin/openrocket
echo "exec java -jar /usr/lib/openrocket/OpenRocket-$upstream.jar \"\$@\"" >> /usr/bin/openrocket
chmod +x /usr/bin/openrocket
[ "$verbose" != "yes" ] || ( get_installed_version && echo "OpenRocket version: $installed" )
fi # end if installed != upstream
[ "$verbose" != "yes" ] || echo "end of action $ACTION"
;;
--uninstall)
[ "$verbose" != "yes" ] || echo "selected action = $ACTION"
[ "$verbose" != "yes" ] || echo "removing files ..."
rm -f /usr/lib/openrocket/*.jar
[ "$verbose" != "yes" ] || echo "end of action $ACTION"
;;
--status)
[ "$verbose" != "yes" ] || echo "selected action = $ACTION"
get_installed_version
echo "OpenRocket version installed on this system : $installed"
get_upstream_version
echo "OpenRocket version available on upstream site: $upstream"
[ "$verbose" != "yes" ] || echo "end of action $ACTION"
;;
*)
do_cleanup
show_usage
;;
esac
do_cleanup
[ "$verbose" != "yes" ] || echo "end of update-openrocket"
|