4
4
# @brief Common shell functions used across multiple workflows
5
5
# @author Michael Hucka <[email protected] >
6
6
# @license Please see the file named LICENSE in the project directory
7
- # @website https://github.com/caltechlibrary/microarchiver
7
+ # @website https://github.com/caltechlibrary/pubarchiver
8
8
#
9
9
# The code below assumes the following variables are set by the calling code:
10
10
#
19
19
# * SLACK_CHANNEL: Slack channel to send notifications of failure or success
20
20
# * SLACK_CLI_TOKEN: used by slack-cli for the Slack API token
21
21
#
22
- # The code below also assumes that programs "microarchiver " and "slack" (the
22
+ # The code below also assumes that programs "pubarchiver " and "slack" (the
23
23
# latter from https://github.com/rockymadden/slack-cli) are on the calling
24
24
# user's command search $path.
25
25
# =============================================================================
26
26
27
- run_microarchiver () {
27
+ run_pubarchiver () {
28
28
# We have only two cases, Portico and PMC, so this grungy approach is good
29
29
# enough for now. Future revisions should generalize this, though.
30
30
destination=Portico
@@ -37,12 +37,12 @@ run_microarchiver() {
37
37
done
38
38
shopt -u nocasematch
39
39
40
- # Next, make sure we can find microarchiver . If not, send mail & quit.
41
- if ! command -v microarchiver & > /dev/null; then
40
+ # Next, make sure we can find pubarchiver . If not, send mail & quit.
41
+ if ! command -v pubarchiver & > /dev/null; then
42
42
body=$( cat << EOF
43
- This is an error message generated by the process running microarchiver for
43
+ This is an error message generated by the process running pubarchiver for
44
44
uploading publications to $destination . The process is unable to find the
45
- program "microarchiver ". This indicates either a configuration problem or
45
+ program "pubarchiver ". This indicates either a configuration problem or
46
46
a change in the computer system where the process is executed. Manual
47
47
intervention is required. Additional information may be found here:
48
48
@@ -52,15 +52,15 @@ intervention is required. Additional information may be found here:
52
52
This message was produced by $mainscript on ` hostname` .
53
53
EOF
54
54
)
55
- echo " $body " | mail -s" microarchiver failure $today " $EMAIL_FAILURE
55
+ echo " $body " | mail -s" pubarchiver failure $today " $EMAIL_FAILURE
56
56
run_slack chat send --channel $SLACK_CHANNEL --color " #ff0000" \
57
57
--title " Error: unable to upload micropublication.org to $destination " \
58
- --text " $mainscript on ` hostname` cannot find program 'microarchiver '"
58
+ --text " $mainscript on ` hostname` cannot find program 'pubarchiver '"
59
59
exit 1
60
60
fi
61
61
62
- # Run microarchiver with arguments and save output in $log
63
- count=$( microarchiver $@ 2>&1 | tee -a $log | grep " Total articles" | cut -d ' ' -f3)
62
+ # Run pubarchiver with arguments and save output in $log
63
+ count=$( pubarchiver $@ 2>&1 | tee -a $log | grep " Total articles" | cut -d ' ' -f3)
64
64
65
65
# If successful, return the num. of articles written, else send mail & quit
66
66
status=$?
74
74
* ) cause=" An unexpected error occurred during execution" ;;
75
75
esac
76
76
body=$( cat << EOF
77
- This is an error message generated by the process running microarchiver for
78
- uploading publications to $destination . While doing its work, microarchiver has
77
+ This is an error message generated by the process running pubarchiver for
78
+ uploading publications to $destination . While doing its work, pubarchiver has
79
79
encountered the following error:
80
80
81
81
$cause
@@ -86,12 +86,12 @@ bottom the log file to see what was the last action attempted.
86
86
Today's upload to $destination has been stopped.
87
87
EOF
88
88
)
89
- echo " $body " | mail -s" microarchiver failure $today " -a $log $EMAIL_FAILURE
89
+ echo " $body " | mail -s" pubarchiver failure $today " -a $log $EMAIL_FAILURE
90
90
run_slack chat send --channel $SLACK_CHANNEL --color " #ff0000" \
91
91
--title " Error: unable to complete $destination archiving for micropublication.org" \
92
- --text " microarchiver failed to create archive file for $destination . Cause: $cause ."
92
+ --text " pubarchiver failed to create archive file for $destination . Cause: $cause ."
93
93
run_slack file upload --channels $SLACK_CHANNEL --file $log \
94
- --comment " Here is the microarchiver run log:"
94
+ --comment " Here is the pubarchiver run log:"
95
95
exit $status
96
96
fi
97
97
}
@@ -118,7 +118,7 @@ run_curl() {
118
118
# First, make sure we can find curl. If not, send mail & quit.
119
119
if ! command -v curl & > /dev/null; then
120
120
body=$( cat << EOF
121
- This is an error message generated by the process running microarchiver for
121
+ This is an error message generated by the process running pubarchiver for
122
122
uploading publications to $destination . The process is unable to find the
123
123
program "curl". This indicates either a configuration problem or a
124
124
change in the computer system where the process is executed. Manual
145
145
# The 2nd-to-last line will have a message from curl.
146
146
problem=$( tail -n 2 $log | head -n 1)
147
147
body=$( cat << EOF
148
- This is an error message generated by the process running microarchiver for
148
+ This is an error message generated by the process running pubarchiver for
149
149
uploading publications to $destination . The "curl" command used to upload files to
150
150
$destination failed with the following return status:
151
151
162
162
--title " Error: unable to complete PMC upload for micropublication.org" \
163
163
--text " $mainscript unable to ftp to $destination . Cause: $problem ."
164
164
run_slack file upload --channels $SLACK_CHANNEL --file $log \
165
- --comment " Here is the microarchiver run log:"
165
+ --comment " Here is the pubarchiver run log:"
166
166
exit $status
167
167
fi
168
168
}
0 commit comments