Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
O
OHR Support
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
97
Issues
97
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
OHR Support
Commits
154c9b4e
Commit
154c9b4e
authored
Oct 05, 2011
by
egarcia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first attempt at sending emails
parent
905ad819
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
2 deletions
+36
-2
Rakefile
backup/Rakefile
+28
-2
smtp.yml.sample
backup/smtp.yml.sample
+8
-0
No files found.
backup/Rakefile
View file @
154c9b4e
...
...
@@ -69,6 +69,12 @@ SSH_USERS = {
'production'
=>
'egarcia'
}
f
=
File
.
open
(
'smtp.yml'
)
SMTP
=
YAML
::
load
(
f
)
f
.
close
puts
SMTP
.
inspect
# =========== END OF CUSTOMIZABLE SETTINGS =============
# Server urls. Used for obtaining the list of svn repositories
...
...
@@ -117,8 +123,27 @@ def repository_exists?(repository)
local_repository_list
.
include?
repository
end
def
shell
(
command
)
def
send_email
(
subject
,
body
)
Pony
.
mail
(
:to
=>
[
'to'
],
:subject
=>
"Error in OHWR backup:
#{
subject
}
"
,
:body
=>
body
,
:via
=>
:smtp
,
:attachments
=>
[],
:via_options
=>
{
:address
=>
SMTP
[
'server'
],
:port
=>
SMTP
[
'port'
],
:enable_starttls_auto
=>
true
,
:user_name
=>
SMTP
[
'user_name'
],
:password
=>
SMTP
[
'password'
],
:authentication
=>
:plain
,
# :plain, :login, :cram_md5, no auth by default
:domain
=>
SMTP
[
'domain'
]
# the HELO domain provided by the client to the server
}
)
end
def
shell
(
command
)
err
=
StringIO
.
new
status
=
Open4
::
popen4
(
command
)
do
|
pid
,
stdin
,
stdout
,
stderr
|
...
...
@@ -128,6 +153,7 @@ def shell(command)
if
status
.
exitstatus
==
0
then
log
"
#{
command
}
- ok"
else
send_email
(
"(
#{
status
.
exitstatus
}
) -
#{
command
}
"
,
err
.
string
)
fail
(
"Command failed(
#{
status
.
exitstatus
}
) -
#{
command
}
:
\n
#{
err
.
string
}
"
)
end
end
...
...
@@ -181,7 +207,7 @@ namespace :backup do
task
:prepare_folders
do
title
"Preparing local folders"
[
LOCAL_REPOSITORY_PATH
,
LOCAL_GIT_PATH
,
LOCAL_DB_PATH
,
LOCAL_FILES_PATH
,
File
.
join
(
LOCAL_SYMPA_PATH
,
'arc'
),
File
.
join
(
LOCAL_SYMPA_PATH
,
'list_data'
)].
each
do
|
path
|
shell
"mkdir
-p
#{
path
}
"
shell
"mkdir
#{
path
}
"
end
end
...
...
backup/smtp.yml.sample
0 → 100644
View file @
154c9b4e
to: 'egarcia@splendeo.es'
server: 'smtp.gmail.com'
port: '587'
user_name: 'contact@splendeo.es'
password: 'secret'
domain: 'splendeo.es'
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