-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathccs-push
More file actions
executable file
·90 lines (79 loc) · 2.6 KB
/
ccs-push
File metadata and controls
executable file
·90 lines (79 loc) · 2.6 KB
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
#!/bin/bash
# This file is part of ccs-push
#
# Developed for the LSST Data Management System.
# This product includes software developed by the LSST Project
# (https://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU 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 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 <https://www.gnu.org/licenses/>.
# Files are transferred to the remote system and then linked
# so they instantly appear to the OODS and DBB services. This
# is done so a service doesn't start processing while a file
# is in the process of being transferred.
#usage info
usage_msg="usage: $0 -h hostname -c (auxtel|comcam|maintel) -s subdir -f filename"
# argument parsing
while getopts c:df:h:s: option
do
case "${option}" in
# camera
c)
if [[ "$OPTARG" == "auxtel" || "$OPTARG" == "comcam" || "$OPTARG" == "maintel" ]];
then
camera=${OPTARG}
else
echo "$usage_msg"
exit 1
fi;;
# file name
f)
filename=${OPTARG}
;;
# host to transfer to
h)
oods_hostname=${OPTARG}
;;
# subdirectory (can be a, a/b, a/b/c, etc.)
s)
sub_dir=${OPTARG}
;;
*)
echo "$usage_msg"
exit 1
;;
esac
done
# check to see of all required arguments exist
if [[ -z "$camera" ]] || [[ -z "$filename" ]] || [[ -z "$oods_hostname" ]] || [[ -z "$sub_dir" ]];
then
echo "$usage_msg"
exit 1
fi
# file name to create on remote side
remote_file=$(basename "$filename")
# set the ssh login
oods_login=saluser@$oods_hostname
# directory where files are first staged from the camera
staging_root=/data/staging/$camera/camera/$sub_dir
# files where files are linked for the OODS
oods_landing_root=/data/staging/$camera/oods/$sub_dir
# link the file to the OODS directory
# shellcheck disable=SC2029
ssh "$oods_login" "\
mkdir -p $staging_root && \
mkdir -p $oods_landing_root && \
cat > $staging_root/$remote_file && \
mv $staging_root/$remote_file $oods_landing_root/$remote_file" <"$filename"