Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pve-manager
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
pve-manager
Commits
1056f33a
Commit
1056f33a
authored
Jun 19, 2013
by
Dietmar Maurer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow to send notification mail about new packages.
parent
5df54893
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
3 deletions
+53
-3
APT.pm
PVE/API2/APT.pm
+40
-1
pve
bin/cron/daily/pve
+13
-2
No files found.
PVE/API2/APT.pm
View file @
1056f33a
...
...
@@ -3,6 +3,7 @@ package PVE::API2::APT;
use
strict
;
use
warnings
;
use
File::
stat
();
use
IO::
File
;
use
File::
Basename
;
use
LWP::
UserAgent
;
...
...
@@ -223,6 +224,12 @@ __PACKAGE__->register_method({
additionalProperties
=>
0
,
properties
=>
{
node
=>
get_standard_option
('
pve-node
'),
notify
=>
{
type
=>
'
boolean
',
description
=>
"
Send notification mail about new packages (to email address specified for user 'root
\
@pam
').
",
optional
=>
1
,
default
=>
0
,
},
},
},
returns
=>
{
...
...
@@ -244,7 +251,39 @@ __PACKAGE__->register_method({
PVE::Tools::
run_command
(
$cmd
);
&
$update_pve_pkgstatus
();
my
$pkglist
=
&
$update_pve_pkgstatus
();
if
(
$param
->
{
notify
}
&&
scalar
(
@$pkglist
))
{
my
$usercfg
=
PVE::Cluster::
cfs_read_file
("
user.cfg
");
my
$rootcfg
=
$usercfg
->
{
users
}
->
{'
root@pam
'}
||
{};
my
$mailto
=
$rootcfg
->
{
email
};
if
(
$mailto
)
{
my
$hostname
=
`
hostname -f
`
||
PVE::INotify::
nodename
();
chomp
$hostname
;
my
$data
=
"
Content-Type: text/plain;charset=
\"
UTF8
\"\n
";
$data
.=
"
Content-Transfer-Encoding: 8bit
\n
";
$data
.=
"
FROM: <root
\
@
$hostname
>
\n
";
$data
.=
"
TO:
$mailto
\n
";
$data
.=
"
SUBJECT: New software packages available (
$hostname
)
\n
";
$data
.=
"
\n
";
$data
.=
"
The following updates are available:
\n\n
";
foreach
my
$p
(
sort
{
$a
->
{
Package
}
cmp
$b
->
{
Package
}
}
@$pkglist
)
{
$data
.=
"
$p
->{Package}:
$p
->{OldVersion} ==>
$p
->{Version}
\n
";
}
my
$fh
=
IO::
File
->
new
("
|sendmail -B 8BITMIME
$mailto
")
||
die
"
unable to open 'sendmail' - $!
";
print
$fh
$data
;
$fh
->
close
();
}
}
return
;
};
...
...
bin/cron/daily/pve
View file @
1056f33a
...
...
@@ -29,13 +29,24 @@ my $nodename = PVE::INotify::nodename();
eval
{
PVE::API2::
Subscription
->
update
({
node
=>
$nodename
});
};
if
(
my
$err
=
$@
)
{
syslog
('
err
',
"
update subscription info failed:
$err
");
syslog
('
err
',
"
update subscription info failed:
$err
");
}
my
$dccfg
=
PVE::Cluster::
cfs_read_file
('
datacenter.cfg
');
eval
{
PVE::APLInfo::
update
(
$dccfg
->
{
http_proxy
});
};
if
(
my
$err
=
$@
)
{
syslog
('
err
',
"
update appliance info failed - see /var/log/pveam.log for details
");
syslog
('
err
',
"
update appliance info failed - see /var/log/pveam.log for details
");
}
if
(
my
$info
=
PVE::INotify::
read_file
('
subscription
'))
{
# We assume that users with subscriptions want informations
# about new packages.
if
(
$info
->
{
status
}
eq
'
Active
')
{
eval
{
PVE::APL2::
APT
->
update_database
({
node
=>
$nodename
,
notify
=>
1
});
};
if
(
my
$err
=
$@
)
{
syslog
('
err
',
"
update apt database failed:
$err
");
}
}
}
sub
cleanup_tasks
{
...
...
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