源脚本来自 http://forums.dropbox.com/topic.php?id=12153, 但是不能支持代理服务器, 主要问题是它的”联网检测”用的是ping, Felix将其改成了wget然后判断页面上是否有forums
Patch 如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
--- a/dbupdate +++ b/dbupdate @@ -37,7 +37,7 @@ declare -r useCount="http://bit.ly/dbupdate_count"; declare -r nIcon="/usr/share/icons/hicolor/64x64/apps/dropbox.png"; declare -r userAgent="Mozilla/5.0 (X11; U; Linux i686; $LANG; rv:1.9.1.3) Gecko/20090924 Ubuntu/9.10 (karmic) Firefox/3.5.3"; -declare -r internetTest="ping -c3 -w10 www.dropbox.com | grep -c '64 bytes'" ; +declare -r internetTest="wget -qO - http://www.dropbox.com | grep -c 'forums'" ; bit="auto"; testing=0; q="-q"; @@ -292,7 +292,7 @@ #test connectivity printf "Checking for connectivity to Dropbox servers..."; -if [ `eval $internetTest` -lt 3 ]; then { +if [ `eval $internetTest` -lt 1 ]; then { echo " FAIL."; echo "Failed to connect to \"www.dropbox.com\""; exit 1; |
以下是修改后完整的 0.2.17 版的脚本:
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 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 |
#!/bin/bash #Originally authored by Dusten Barker. Originally created on 07sep09. #Thanks to contributions by Herbert S., Udi M., Olivier G., Darren S., and Luke S. of #the Dropbox Forums, and to Andy Piper of http://andypiper.co.uk! # GNU LGPL Notice # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # 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 Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # Dropbox <http://www.dropbox.com> is a proprietary cross-platform backup and # syncing software, currently available for Linux, Mac OSX, and MS Windows. # # dbupdate <http://forums.dropbox.com/topic.php?id=12153> is a script written # to automatically upgrade the experimental build of Dropbox, which does not # provide a software upgrade option such as found within the stable builds. # # dbupdate makes use of portions of the Dropbox project to function, such as the # dropbox executable binary and its graphics. # Please feel free to leave comments, bug reports, suggestions, and polite # criticisms about this script in the Dropbox Forums thread pertaining to # this script. #init declare -r ver="0.2.17"; declare -r verdate="25jul10"; declare -r useCount="http://bit.ly/dbupdate_count"; declare -r nIcon="/usr/share/icons/hicolor/64x64/apps/dropbox.png"; declare -r userAgent="Mozilla/5.0 (X11; U; Linux i686; $LANG; rv:1.9.1.3) Gecko/20090924 Ubuntu/9.10 (karmic) Firefox/3.5.3"; declare -r internetTest="wget -qO - http://www.dropbox.com | grep -c 'forums'" ; bit="auto"; testing=0; q="-q"; unset altInst; unset tmpDir; unset bitVer; unset curVer; unset newVer; unset newFile; unset getFile; unset fVer; unset delay; unset pstring; unset noUseCheck; unset pstring; unset tmpStr; unset root; unset notifier; unset check; unset upgrade; unset overwriteIcons; unset limit; unset iscript; unset lock; _displayOpt () #help screen { echo; echo "Dropbox Updater v"$ver"-"$verdate", written by Dusten Barker."; echo "USAGE: dbupdate OPTION..."; echo "Option \"-b auto\" is implied by default unless otherwise specified."; echo "ex: \"dbupdate -gb32 -f0.7.28\""; echo "ex: \"dbupdate -nud 45s\""; echo; echo " Options:"; echo " -b 32, 64, or auto"; echo " 32 use 32 bit Dropbox version"; echo " 64 use 64 bit Dropbox version"; echo " auto automatically determine 32 or 64 bit; default"; echo " -c check if update is available"; echo " -d TIME delay for TIME; ex: 30s, 2m, &c..."; echo " -f force version, implies -u"; echo " -g use graphical download progress indicator"; echo " -h display this screen"; echo " -i HOURS install, requires su/sudo/root"; echo " 0 remove cronjob and install, place dbupdate in path"; echo " #>0 number of hours to wait between update checks"; echo " -l RATE limit bandwidth to RATE; ex: 320k, 1.2m, &c..."; echo " -n use notifier, if installed (/usr/bin/notify-send)"; echo " -o overwrite icons, do not preserve"; echo " -r allow use as root user"; echo " -u perform update. implies -c unless -f"; echo " -x do not send use count"; echo; } _checkExit () #check exit status { if [ ! $? -eq 0 ]; then { echo "Error $? returned."; echo "Aborting."; exit 2; } fi; } _compareVer () #two-dot comparator script-foo { unset _compareVerGT; unset _compareVerLT; unset ver1Maj; unset ver1Min; unset ver1Pat; unset ver2Maj; unset ver2Min; unset ver2Pat; ver1Maj="$(echo $1 | cut -d'.' -f1)"; ver1Min="$(echo $1 | cut -d'.' -f2)"; ver1Pat="$(echo $1 | cut -d'.' -f3)"; ver2Maj="$(echo $2 | cut -d'.' -f1)"; ver2Min="$(echo $2 | cut -d'.' -f2)"; ver2Pat="$(echo $2 | cut -d'.' -f3)"; if [ $ver1Pat -ne $ver2Pat ]; then if [ $ver1Pat -gt $ver2Pat ]; then { _compareVerGT=$1; _compareVerLT=$2; } else { _compareVerGT=$2; _compareVerLT=$1; } fi; fi; if [ $ver1Min -ne $ver2Min ]; then if [ $ver1Min -gt $ver2Min ]; then { _compareVerGT=$1; _compareVerLT=$2; } else { _compareVerGT=$2; _compareVerLT=$1; } fi; fi; if [ $ver1Maj -ne $ver2Maj ]; then if [ $ver1Maj -gt $ver2Maj ]; then { _compareVerGT=$1; _compareVerLT=$2; } else { _compareVerGT=$2; _compareVerLT=$1; } fi; fi; if [ $1 = $2 ]; then { _compareVerGT=$1; _compareVerLT=0; }; fi; } _installdbupdate () #install script to path and control cron job { tmpStr="dbupdate" if [ $iscript -eq 0 ]; then { if [ ! -d "/usr/share/dbupdate" ]; then { mkdir /usr/share/dbupdate ; _checkExit; } fi; if [ ! -d "/usr/share/dbupdate/dbupdate$ver" ]; then { mkdir /usr/share/dbupdate/dbupdate$ver ; _checkExit; } fi; cp $0 /usr/share/dbupdate/dbupdate$ver/ ; _checkExit; chmod +x /usr/share/dbupdate/dbupdate$ver/$(basename $0) ; _checkExit; ln -fs /usr/share/dbupdate/dbupdate$ver/$(basename $0) /usr/bin/dbupdate ; _checkExit; sed -i "/$tmpStr/d" /etc/crontab; } fi; if [ $iscript -ne 0 ]; then { if [ ! $SUDO_USER ]; then SUDO_USER=root; fi; sed -i "/$tmpStr/d" /etc/crontab; echo "0 */$1 * * * $SUDO_USER if [ -e /usr/bin/dbupdate ]; then export DISPLAY=:0.0; dbupdate -nu; fi;" >> /etc/crontab } fi; } _dbVer () #get version of current dropbox install { if [ ! -f ~/.dropbox-dist/VERSION ]; then { echo "FAIL!"; echo "Dropbox version not detected. Aborting."; exit 1; } else { read curVer < ~/.dropbox-dist/VERSION ; } fi; } _notify () #notify-osd, if present { if [ $notifier ]; then { if [ -e "/usr/bin/notify-send" -a -e $nIcon ]; then { if [ "$1" = "upgrade" ]; then { eval "/usr/bin/notify-send -i $nIcon 'Upgrade complete.' 'dbupdate has upgraded Dropbox on this computer to v"$newVer"'" ; _checkExit; } fi; if [ "$1" = "check" ]; then { eval "/usr/bin/notify-send -i $nIcon 'Upgrade available.' 'dbupdate has found an available Dropbox upgrade to v"$newVer"'" ; _checkExit; } fi; if [ "$1" = "checkupgrade" ]; then { eval "/usr/bin/notify-send -i $nIcon 'Upgrade available.' 'dbupdate has found an available Dropbox upgrade to v"$newVer" and is downloading it now.'" ; _checkExit; } fi; } fi; } fi; } _bitAutodetect () #detect for 64bit or 32bit installed dropbox { if [ -d ~/.dropbox-dist/ncrypt*linux-x86_64.egg/ ]; then { bit=64; } else if [ -d ~/.dropbox-dist/ncrypt*linux-i686.egg/ ]; then { bit=32; } else if [ $(uname -m) == "i386" ] || [ $(uname -m) == "i586" ] || [ $(uname -m) == "i686" ]; then { bit=32; } else if [ $(uname -m) == "x86_64" ]; then { bit=64; } else { echo " FAIL."; echo "Try forcing architecture with \"-b\"."; exit 1; } fi; fi; fi; fi; } # ------------------------- main ------------------------------ if [ "$1" == "moo" ]; then { echo "You're wrong if you think I have super cow powers."; exit 0; } fi; #check if already running printf "Getting file lock..."; lock="/tmp/$(basename $0).LCK"; exec 8>$lock; #send to handler 8 if flock -n -e 8; then : else { echo " FAIL."; echo "Cannot lock $0. Aborting."; exit 1; } fi; echo " Done."; #gather options from command line and set flags if [ $# -eq 0 ]; then echo "Use \"$0 -h\" for usage and help."; exit 0; fi; #display message and quit if no command line arguments found while getopts uchxnrgoi:f:t:d:b:l: opt do { case "$opt" in b) if [ "$OPTARG" = "32" ]; then bit=$OPTARG; else if [ "$OPTARG" = "64" ]; then bit=$OPTARG; else if [ "$OPTARG" = "auto" ]; then bit=$OPTARG; else { echo "The -b option argument \"$OPTARG\" is invalid."; echo "Use \"$0 -h\" for usage and help."; exit 1; } fi; fi; fi;; d) delay=$OPTARG;; u) upgrade=1; check=1;; c) check=1;; h) _displayOpt; exit 0;; t) notifier=1; #test option for notifier - hidden flag _notify $OPTARG; exit 0;; x) noUseCheck=1;; n) notifier=1;; f) fVer=$OPTARG; upgrade=1;; l) limit="--limit-rate="$OPTARG;; i) iscript=$OPTARG;; o) overwriteIcons=1;; g) if [ -e "/usr/bin/zenity" ]; then pstring="2>&1 | sed -u 's/.* \([0-9]\+%\)\ \+\([0-9.]\+.\) \(.*\)/\1\n# Downloading at \2\/s, ETA \3/' | zenity --progress --auto-close --title='dbupdate - Dropbox...' "; unset q; else echo "Cannot use progress indicator."; fi;; r) root=1;; \?) echo "Use \"$0 -h\" for usage and help."; exit 1;; esac; } done; shift `expr $OPTIND - 1`; #check root; if [ ! $iscript ] && [ ! $root ]; then { if [ $EUID -eq 0 ]; then { echo "dbupdate only requires root during install-type procedures."; echo "If you require use by root user, force with the \"-r\" option."; exit 1; } fi; } fi; if [ $root ] && [ $EUID -ne 0 ]; then { echo "You can not use \"-r\" flag unless you are root."; exit 1; } fi; #delay, if any if [ $delay ]; then { printf "Waiting for $delay..."; sleep $delay; _checkExit; echo " Done."; } fi; #test for or create temporary space if [ $check ] || [ $fVer ]; then { printf "Looking for temporary space..."; tmpDir=`mktemp -d` ; _checkExit; if [ -d $tmpDir ]; then { echo " Created."; } else { echo "FAIL."; echo; echo "Could not create $tmpDir"; exit 1; } fi; } fi; #self-install if [ $iscript ] && [ ! $EUID -eq 0 ]; then { echo "You must be root to use the \"-i\" option."; exit 1; } fi; if [ $iscript ]; then { printf "Installing dbupdate..."; _installdbupdate $iscript; echo " Done."; exit 0; } fi; #check for alternate install printf "Checking for alternate install..."; if [ -e ~/.dropbox-alt/dropbox ]; then { echo " Found."; altInst=1; } else { echo " Not found."; } fi; #test connectivity printf "Checking for connectivity to Dropbox servers..."; if [ `eval $internetTest` -lt 1 ]; then { echo " FAIL."; echo "Failed to connect to \"www.dropbox.com\""; exit 1; } fi; echo " Done."; #autodetect 32 or 64 bit dropbox install if [ "$bit" = "auto" ]; then { printf "Detecting Dropbox architecture..."; _bitAutodetect; printf " Done."; } else { printf "Forcing Dropbox architechture... Done."; } fi; if [ $bit = 32 ]; then { bitVer=""; echo " (32bit)"; } fi; if [ $bit = 64 ]; then { bitVer="_64"; echo " (64bit)"; } fi; #determine currently installed version if [ $check ] && [ ! $fVer ]; then { printf "Checking currently installed version..."; _dbVer; echo " Done. ($curVer)"; } fi; #see if forced version if [ $fVer ]; then newVer=$fVer; curVer="0.0.0"; else { #if not forced version, CHECK for latest version if [ $check ]; then { printf "Checking for update..."; newVer1=`wget -q --tries=3 -O - www.dropbox.com/release_notes/rss.xml | xpath -q -e "//channel/item[1]/title" | sed "s@<\([^<>][^<>]*\)>\([^<>]*\)</\1>@\2@g" | sed -e "y/\t/ /;s/ *$//;s/^.* //"`; #sanity test; check for expected output format if [ ! $(echo $newVer1 | tr -dc '.' | wc -c) -eq 2 ] || [ $(echo $newVer1 | awk '{print gsub("[0-9]", "")}') -le 3 ]; then { echo " FAIL."; exit 1; } fi; echo " Done."; if [ ! $noUseCheck ]; then { eval "wget -q $limit --referer='http://dbupdate_use_count/$ver' --user-agent='$userAgent' -O /dev/null $useCount"; } fi; _compareVer $newVer1 $curVer; newVer=$_compareVerGT; if [ $_compareVerLT = 0 ]; then { echo "$curVer is the latest available version. Update not required."; exit 0; } fi; if [ ! $upgrade ]; then { echo "Dropbox v$curVer can be updated to v$newVer"; _notify check; exit 0; } fi; _notify checkupgrade; } fi; } fi; #preserve icons if [ ! $overwriteIcons ]; then { _compareVer $curVer 0.8.55; if [ $_compareVerGT = $curVer ]; then { printf "Backing up icons..."; mkdir $tmpDir/backupIcons ; _checkExit; if [ -d ~/.dropbox-dist/icons/ ]; then { cp -r ~/.dropbox-dist/icons/* $tmpDir/backupIcons ; _checkExit; echo " Done."; } else { echo "Does not exist. Skipping."; unset overwriteIcons; } fi; } fi; } fi; #download upgrade if [ $upgrade ]; then { printf "Downloading update. This may take a few minutes..."; newFile="dropbox-lnx.x86"$bitVer"-"$newVer".tar.gz" ; getFile="http://dl.dropbox.com/u/17/"$newFile ; eval "wget $q $limit --referer='http://dbupdate' --user-agent='$userAgent' -O $tmpDir/$newFile $getFile $pstring &" ; _checkExit; i=1 sp="/-\|" echo -n ' '; while pgrep wget &>/dev/null; do { printf "\b${sp:i++%${#sp}:1}" ; sleep 0.25; } done; echo -e "\b Done"; while [ $testing -eq 0 ]; do { sleep 0.5s; if [ -z "$(pidof zenity)" ]; then { pkill wget; testing=1; if [ ! $? -eq 0 ]; then { echo "Operation cancelled."; exit 1; } fi; } fi; } done; #check download #printf "Verify download..."; if [ ! -e $tmpDir/$newFile ] || [ $(stat -c%s "$tmpDir/$newFile") -le 10000 ]; then { echo " Verify download FAIL."; exit 1; } fi; #echo " Done."; #install upgrade if [ -e /usr/bin/dropbox ]; then { printf "Stopping Dropbox..."; killall -q dropbox; #_checkExit; sleep 1; killall -q dropbox; #_checkExit; sleep 1; echo " Done."; } fi; printf "Installing Dropbox $newVer..."; rm -fr ~/.dropbox-dist ; _checkExit; tar xzf $tmpDir/$newFile -C ~/ ; _checkExit; echo " Done."; #restore icons if [ ! $overwriteIcons ] && [ -d $tmpDir/backupIcons ]; then { printf "Restoring previous icons..."; cp -r $tmpDir/backupIcons/* ~/.dropbox-dist/icons ; _checkExit; echo " Done."; } fi; #install alternate if [ $altInst ]; then { printf "Updating alternate install..."; cp -r ~/.dropbox-dist ~/.dropbox-alt ; _checkExit; echo " Done."; } fi; #start Dropbox printf "Starting Dropbox..."; if [ -e /usr/bin/dropbox ]; then { ~/.dropbox-dist/dropbox start & echo " Done."; } else { ~/.dropbox-dist/dropboxd start -i & echo " Done."; } fi; if [ $altInst ]; then { #start alt printf "Starting alternate Dropbox..."; ~/.dropbox-alt/dropbox start & echo " Done."; } fi; #finish _notify upgrade; echo "Complete."; } fi; rm $lock |
请问楼主脚本是更新dropbox用的吗?如何使用,我刚安装dropbox for linux 不太懂
是更新到最新测试版用的..因此您可以不用尝试….
推介各位嘗試SugarSync,功能跟Dropbox一樣。
而且沒有被大陸封鎖。(Dropbox已被大陸封鎖了)
注冊及安裝鏈接,可直接增加500MB空間。
https://www.sugarsync.com/referral?rf=d776qx56sv3nx
SugarSync貌似没有Linux下的客户端,所以我就不考虑了:)
另外请问,SugarSync有保存文件每次修改的版本的功能吗?