-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from mlibrary/sms
Move sms script to this repo
- Loading branch information
Showing
22 changed files
with
428 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
Empty file.
This file contains 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
This file contains 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
This file contains 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,38 @@ | ||
#!/bin/bash | ||
|
||
echo "📋 Check for dependencies" | ||
if ! command -v ssh-keygen &> /dev/null | ||
then | ||
echo "❌ ssh-keygen could not be found" | ||
exit | ||
fi | ||
echo "✅ ssh-keygen found" | ||
|
||
|
||
echo "🧹 clear out any existing ssh keys" | ||
rm -f .ssh/* | ||
rm -f sftp/ssh/ssh_host* | ||
rm -f ssh_host* | ||
|
||
|
||
echo "🔑 generate the host ssh keys for the sftp service" | ||
ssh-keygen -t ed25519 -f ssh_host_ed25519_key < /dev/null | ||
ssh-keygen -t rsa -b 4096 -f ssh_host_rsa_key < /dev/null | ||
|
||
|
||
echo "🛻 move the keys into the sftp/ssh directory so they can be picked up" | ||
echo "by docker-compose bind mounts for the sftp service" | ||
mv ssh_host_ed25519_key sftp/ssh/ | ||
mv ssh_host_rsa_key sftp/ssh/ | ||
#this seems to be necessary | ||
mv ssh_host_rsa_key.pub .ssh/known_hosts | ||
|
||
echo "🧹 remove the unnecessary files" | ||
rm ssh_host* | ||
|
||
echo "🔑 generate actual host login keys" | ||
ssh-keygen -t rsa -b 4096 -f ssh_client_rsa_key < /dev/null | ||
|
||
echo "🛻 move the keys into the sftp/ssh directory" | ||
mv ssh_client_rsa_key.pub sftp/ssh/ | ||
mv ssh_client_rsa_key sftp/ssh/ |
This file contains 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,3 @@ | ||
#!/bin/bash | ||
|
||
sftp -oIdentityFile=${SFTP_SSH_KEY_PATH} -oStrictHostKeyChecking=no ${SFTP_USER}@${SFTP_HOST} |
This file contains 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,5 @@ | ||
#!/bin/bash | ||
|
||
#must be run from the project root directory | ||
cp ./spec/fixtures/sms/sample_message.txt ./sftp/sms/FulSomeFile.txt | ||
rm -f ./sftp/sms/processed/*.txt |
This file contains 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
This file contains 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,7 @@ | ||
SMS_DIR='sms' | ||
PROCESSED_SMS_DIR='sms/processed' | ||
SFTP_HOST='sftp' | ||
SFTP_USER='alma' | ||
SFTP_SSH_KEY_PATH="/etc/secret-volume/id_rsa" | ||
PROMETHEUS_JOB_NAME=send_alma_sms | ||
PROMETHEUS_PUSH_GATEWAY=http://pushgateway:9091 |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,37 @@ | ||
require "json" | ||
require "twilio-ruby" | ||
require "telephone_number" | ||
require "fileutils" | ||
require "logger" | ||
require "yabeda" | ||
require "yabeda/prometheus" | ||
|
||
require "sftp" | ||
|
||
require "aim/sms/sender" | ||
|
||
module AIM | ||
module SMS | ||
def self.configure | ||
::Yabeda.configure do | ||
gauge :aim_send_sms_last_success, comment: "Time that Alma sms messages were successfully sent" | ||
gauge :aim_send_sms_num_messages_sent, comment: "Number of Alma sms messages sent in a job" | ||
gauge :aim_send_sms_num_messages_not_sent, comment: "Number of Alma sms messages that caused an error" | ||
gauge :aim_send_sms_num_messages_error, comment: "Number of Alma sms messages that were NOT successfully sent" | ||
end | ||
Yabeda.configure! | ||
end | ||
|
||
def self.send_metrics(results) | ||
Yabeda.aim_send_sms_num_messages_sent.set({}, results[:num_files_sent]) | ||
Yabeda.aim_send_sms_num_messages_not_sent.set({}, results[:num_files_not_sent]) | ||
Yabeda.aim_send_sms_num_messages_error.set({}, results[:num_files_error]) | ||
Yabeda.aim_send_sms_last_success.set({}, results[:start_time]) | ||
begin | ||
Yabeda::Prometheus.push_gateway.add(Yabeda::Prometheus.registry) | ||
rescue | ||
Logger.new($stdout).error("Failed to contact the push gateway") | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.