aboutsummaryrefslogtreecommitdiff
path: root/scripts/install-indexers
blob: ff0bd0d6fdcc483c94c2bf4b1bcc5f0f75ba8ff5 (plain)
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
#!/bin/sh

# Set the installation location here
# Executables will be placed in $CFPREFIX/bin
CFPREFIX=/usr

# Set the location of syminfo.lib here
SYMINFO=/usr/local/share/ccp4/syminfo.lib

SYS=`uname -sm`
if [ "$SYS" == "Linux x86_64" ]; then
	MOSFLM=mosflm-linux-64-noX11
	DIRAX=dirax1.17-Linux-x86_64-static.tar.Z
	DIRAX_TAR_ARGS=-xZf
	XDS=XDS-INTEL64_Linux_x86_64
	PLATFORM="Linux x86_64"
fi

if [ "$SYS" == "Linux i686" ]; then
	MOSFLM=mosflm-linux-32-noX11
	DIRAX=dirax1.17-Linux-i686-static.tar.Z
	DIRAX_TAR_ARGS=-xZf
	XDS=x
	PLATFORM="Linux x86 (32 bit)"
fi

if [ "$SYS" == "Darwin x86_64" ]; then
	MOSFLM=mosflm-linux-64-noX11
	DIRAX=dirax1.16-Darwin-x86_64.tar.gz
	DIRAX_TAR_ARGS=-xzf
	XDS=XDS-OSX_64.tar.gz
	PLATFORM="MacOS x86_64"
fi

if [ "$SYS" == "Darwin arm64" ]; then
	MOSFLM=x
	DIRAX=x
	XDS=XDS-Apple_M1.tar.gz
	PLATFORM="MacOS ARM (Apple silicon)"
fi

if [ "x$PLATFORM" == x ]; then
	echo Could not identify your system: $SYS
	uname -a
	exit 1
fi

if [ x$1 == x--help ]; then
	echo 'This script downloads and installs Mosflm, DirAx and XDS'
	echo
	echo Step 1: $0
	echo Step 2: $0 'install    ' \# perhaps with sudo
	echo
	echo '    Installation location:' $CFPREFIX
	echo 'CCP4 syminfo.lib location:' $SYMINFO '(only needed for Mosflm)'
	echo '                 Platform:' $PLATFORM
	echo
	echo 'To alter the installation location, edit this script.'
	echo
	echo 'Please note the license conditions for each program:'
	echo '   DirAx: http://www.crystal.chem.uu.nl/distr/dirax/'
	echo '  Mosflm: https://www.mrc-lmb.cam.ac.uk/mosflm/mosflm/'
	echo '     XDS: https://xds.mr.mpg.de/'
	exit 0
fi


# Exit immediately if something doesn't work
set -e

if [ x$1 != xinstall ]; then

	if [ x$USER == xroot ]; then
		echo Do not run this as root
		exit 1
	fi

	if [ -d mosflm-tempdir -o -d xds-tempdir -o -d dirax-tempdir ]; then
		echo Delete the following directories before trying again:
		echo mosflm-tempdir xds-tempdir dirax-tempdir
		exit 1
	fi

	echo '    Installation location:' $CFPREFIX
	echo 'CCP4 syminfo.lib location:' $SYMINFO '(only needed for Mosflm)'
	echo '                 Platform:' $PLATFORM
	echo

	if [ x$MOSFLM != xx ]; then

		if [ ! -f $SYMINFO ]; then
			echo Cannot find SYMINFO file at $SYMINFO
			echo -n You need to install libCCP4
			echo ' (separately, or as part of the CrystFEL installation process)'
			echo Or, edit the script to set the correct location
			exit 1
		fi

		mkdir mosflm-tempdir
		pushd mosflm-tempdir
		wget -nv https://www.mrc-lmb.cam.ac.uk/mosflm/mosflm/ver740/pre-built/$MOSFLM.zip
		unzip $MOSFLM.zip
		mv $MOSFLM mosflm.real
		echo '#!/bin/sh' > mosflm
		echo "export SYMINFO=$SYMINFO" >> mosflm
		echo "$CFPREFIX/bin/mosflm.real -n \$@" >> mosflm
		chmod +x mosflm
		popd
	else
		echo "Mosflm is not available for your system."
	fi
	
	if [ x$DIRAX != xx ]; then
		mkdir dirax-tempdir
		pushd dirax-tempdir
		wget -nv http://www.crystal.chem.uu.nl/distr/dirax/download/$DIRAX
		set +e
		tar $DIRAX_TAR_ARGS $DIRAX
		if [ $? != 0 ]; then
			echo You might need to install package \'ncompress\'
			exit 1
		fi
		set -e
		mv dirax dirax.real
		echo "#!/bin/sh" > dirax
		echo "exec $CFPREFIX/bin/dirax.real \"\$@\"" >> dirax
		chmod +x dirax
		popd
	else
		echo Dirax is not available for your system.
	fi
	
	if [ x$XDS != xx ]; then
		mkdir xds-tempdir
		pushd xds-tempdir
		wget -nv https://xds.mr.mpg.de/$XDS.tar.gz
		tar -xzf $XDS.tar.gz
		mv $XDS/xds xds
		popd
	else
		echo XDS is not available for your system.
	fi

else

	if [ ! -f mosflm-tempdir/mosflm.real ]; then
		if [ ! -f xds-tempdir/xds ]; then
			echo Run this script without \'install\' first
			exit 1
		fi
	fi
	set -x

	if [ -f mosflm-tempdir/mosflm ]; then
		install -D mosflm-tempdir/mosflm.real $CFPREFIX/bin/mosflm.real
		install mosflm-tempdir/mosflm $CFPREFIX/bin/mosflm
	fi

	if [ -f dirax-tempdir/dirax ]; then
		install dirax-tempdir/dirax dirax-tempdir/dirax.real $CFPREFIX/bin
		install --mode=644 dirax-tempdir/dirax.commands $CFPREFIX/bin
	fi

	if [ -f xds-tempdir/xds ]; then
		install xds-tempdir/xds $CFPREFIX/bin/xds
	fi

fi