-
Notifications
You must be signed in to change notification settings - Fork 6
- First version of asigra hotfix / update script #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
miwi-fbsd
wants to merge
1
commit into
freenas:master
Choose a base branch
from
miwi-fbsd:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| #!/bin/sh | ||
|
|
||
| #TODO | ||
| # - remove the empty lines in INDEX.n | ||
|
|
||
| UPDATE="https://asigra-f611.kxcdn.com/14.1" | ||
| FILE=INDEX.prev | ||
| DLDIR=download | ||
| IP=`cat /root/dhcpip` | ||
|
|
||
| # Check for if prev index exist if not create | ||
| if [ -f "$FILE" ]; then | ||
| else | ||
| touch $FILE | ||
| fi | ||
|
|
||
| # Check for DLDIR | ||
| if [ -f "$DLDIR" ]; then | ||
| else | ||
| mkdir $DLDIR | ||
| fi | ||
|
|
||
| #fetch index | ||
| curl $UPDATE/INDEX > INDEX | ||
| if [ "$?" -gt 0 ] | ||
| then | ||
| echo "Error downloading INDEX" | ||
| exit 1 | ||
| fi | ||
|
|
||
| #compare if a new file is there | ||
| diff -ruN INDEX.prev INDEX > INDEX.n | ||
|
|
||
| #cut all unneded stuff out | ||
| cut -d: -f4- INDEX.n > INDEX.new | ||
|
|
||
| #We need prev. index to compare | ||
| mv INDEX INDEX.prev | ||
|
|
||
| #When INDEX.new is empty we dont need to do anything | ||
| if [ ! -s "INDEX.new" ] ; then return 0 ; fi | ||
|
|
||
|
|
||
| #Get all files from the new index | ||
| #Curl explaintion: we will retry 5 times or a maximum of 40 seconds with a connection timeout of 5 seconds, and no exponential backoff policy | ||
| for i in $(cat INDEX.new) | ||
| do | ||
| cd $DLDIR && { curl \ | ||
| -O $UPDATE/$i \ | ||
| --fail-early \ | ||
| --connect-timeout 5 \ | ||
| --max-time 300 \ | ||
| --retry 5 \ | ||
| --retry-delay 0 \ | ||
| --retry-max-time 40 ;\ | ||
| cd -; } | ||
| if [ "$?" -ne 0 ] | ||
| then | ||
| echo "Error downloading distfiles" | ||
| exit | ||
| fi | ||
| done | ||
|
|
||
| #DS-Update | ||
| for dsup in download/Update*.zip | ||
| do | ||
| if [ -f "$dsup" ]; then | ||
| unzip $DLDIR/DS-System_*.zip -d $PWD/$DLDIR | ||
| fi | ||
| done | ||
|
|
||
|
|
||
| #DS-System hotfix | ||
| for dssys in $DLDIR/DS-System_*.zip | ||
| do | ||
| if [ -f "$dssys" ]; then | ||
|
|
||
| unzip $DLDIR/DS-System_*.zip -d $PWD/$DLDIR | ||
| pkg add $DLDIR/DS-System_*/dssystem-*.txz | ||
| fi | ||
| done | ||
|
|
||
| #Webinterface hotfix | ||
| for dsop in $DLDIR/DS-Operator_FreeBSD* | ||
| do | ||
| if [ -f "$dsop" ]; then | ||
|
|
||
| #extract the web stuff to the right dir | ||
| unzip -o $DLDIR/DS-Operator*.zip -d /usr/local/www/asigra | ||
|
|
||
| #make sure we have the right IP after the upgrade | ||
| sed -i.bak -E "s|codebase=\"(.+)\"|codebase=\"http://$IP/asigra/\"|" /usr/local/www/asigra/DSOP.jnlp | ||
| rm -f /usr/local/www/asigra/DSOP.jnlp.bak | ||
| fi | ||
| done | ||
|
|
||
| #Cleanup | ||
| rm -rf $DLDIR | ||
|
|
||
| #Restart services | ||
| # workaround for broken rc.d script | ||
| pkill dssystem_dc | ||
| sleep 15; | ||
| /usr/local/etc/rc.d/dssystem start | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
300 seconds is enough to download 3.6GiB?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, thats always dependents on network and location (home or dc), do you think 1200 sec (20 min) would be a good time ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try 2 hours. 10mbit/s connections are still popular around the world.