Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
libcifpp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
libcifpp
Commits
67b6c4bd
Unverified
Commit
67b6c4bd
authored
Feb 05, 2023
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update downloaded files only when needed and clean up afterwards
parent
d84faad1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
23 deletions
+41
-23
tools/update-libcifpp-data.in
+41
-23
No files found.
tools/update-libcifpp-data.in
View file @
67b6c4bd
#!/bin/sh
# Code updated based on a bug report in Ubuntu:
# Bug #1999259 reported by Kyler Laird on 2022-12-09
set
-e
# Get the effective UID, but do so in a compatible way (we may be running dash)
euid
=
${
EUID
:-$(
id
-u
)}
if
[
"
${
euid
}
"
-ne
0
]
;
then
if
[
"
${
euid
}
"
-ne
0
]
;
then
echo
"Please run as root"
exit
fi
if
[
-f
"@CIFPP_ETC_DIR@/libcifpp.conf"
]
;
then
if
[
-f
"@CIFPP_ETC_DIR@/libcifpp.conf"
]
;
then
.
"@CIFPP_ETC_DIR@/libcifpp.conf"
fi
# check to see if we're supposed to run at all
if
[
"
$update
"
!=
"true"
]
;
then
if
[
"
$update
"
!=
"true"
]
;
then
exit
fi
...
...
@@ -24,35 +27,50 @@ if ! [ -d "@CIFPP_CACHE_DIR@" ]; then
exit
fi
fetch_dictionary
()
{
dict
=
$1
source
=
$2
wget
-O
${
dict
}
.gz
${
source
}
# be careful not to nuke an existing dictionary file
# extract to a temporary file first
# Create a temp file in the right directory and
# make sure it is cleaned up when this script exits
gunzip
-c
${
dict
}
.gz
>
${
dict
}
-tmp
tmpfile
=
$(
mktemp
--tmpdir
=
@CIFPP_CACHE_DIR@
)
trap
"rm -f
\"
${
tmpfile
}
\"
"
EXIT
# then move the extracted file to the final location
# Record if updating was really necessary
updated
=
false
mv
${
dict
}
-tmp
${
dict
}
# and clean up afterwards
update_dictionary
()
{
dict
=
$1
source
=
$2
rm
${
dict
}
.gz
# Using curl with
# --location (follow redirects)
# --silent (no diagnostic output at all)
# --time-cond (only fetch if source is newer)
#
# Output is extracted and written to $tmpfile and when successful
# the tmpfile is placed at the desired location and updated is set
# to true
echo
"
${
dict
}
"
curl
--silent
--location
--compressed
--time-cond
"
${
dict
}
"
"
${
source
}
"
|
(
# uncompress the file on the fly, if it is compressed
if
[
"
${
source
%.gz
}
"
!=
"
${
source
}
"
]
;
then
gunzip
-c
>
"
${
tmpfile
}
"
2>/dev/null
else
cat
>
"
${
tmpfile
}
"
fi
)
&&
(
mv
"
${
tmpfile
}
"
"
${
dict
}
"
&&
chmod a+r
"
${
dict
}
"
&&
updated
=
true
)
||
true
}
# fetch the dictionaries
fetch_dictionary
"@CIFPP_CACHE_DIR@/mmcif_pdbx.dic"
"https://mmcif.wwpdb.org/dictionaries/ascii/mmcif_pdbx_v50.dic.gz"
fetch_dictionary
"@CIFPP_CACHE_DIR@/components.cif"
"ftp://ftp.wwpdb.org/pub/pdb/data/monomers/components.cif.gz"
# Update the dictionaries
wget
-O
"@CIFPP_CACHE_DIR@/mmcif_ma.dic"
"https://github.com/ihmwg/ModelCIF/raw/master/dist/mmcif_ma.dic"
update_dictionary
"@CIFPP_CACHE_DIR@/components.cif"
"https://ftp.wwpdb.org/pub/pdb/data/monomers/components.cif.gz"
update_dictionary
"@CIFPP_CACHE_DIR@/mmcif_pdbx.dic"
"https://mmcif.wwpdb.org/dictionaries/ascii/mmcif_pdbx_v50.dic.gz"
update_dictionary
"@CIFPP_CACHE_DIR@/mmcif_ma.dic"
"https://github.com/ihmwg/ModelCIF/raw/master/dist/mmcif_ma.dic"
# notify subscribers, will fail on FreeBSD
if
[
-d
"@CIFPP_ETC_DIR@/libcifpp/cache-update.d"
]
&&
[
-x
/bin/run-parts
]
;
then
if
[
"
${
updated
}
"
!=
"false"
]
&&
[
-d
"@CIFPP_ETC_DIR@/libcifpp/cache-update.d"
]
&&
[
-x
/bin/run-parts
]
;
then
run-parts
--arg
"@CIFPP_CACHE_DIR@"
--
"@CIFPP_ETC_DIR@/libcifpp/cache-update.d"
fi
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment