Commit 97d54874 authored by Francesc Guasch's avatar Francesc Guasch
Browse files

Import original source of ravada 0.1.2

parents
MYMETA.json
MYMETA.yml
Makefile
Makefile.old
blib
pm_to_blib
t/.db
t/etc/ravada_ldap.conf
hypnotoad.pid
log
rvd_front.conf
pkg-debian-out
# Change Log
**Implemented enhancements:**
- Remove base [\#12]
- New machine parameters [\#8]
- make ping localhost packend faster and lighter [\#66]
- Add a form to rename a virtual machine [\#78]
- Rename domains [\#41]
- Spin off bases from clones [\#67]
- Message to the user when downloading ISO [\#77]
- Name (copy) the cloned domains [\#92]
- Requests for the same domain should queue [\#93]
- Rename domains [\#41]
- Log out the user after starting a new machine [\#79]
- Hide and publish bases [\#86]
- Let the users shutdown their machines from the web [\#98]
- Add iptables rules for the domains [\#51]
- Release information in about page [\#62]
- Disable prepare base button for domains with clones [\#89]
- Start a machine must be prioritary [\#97]
**Fixed bugs:**
- Remove file base entries when removing domain [\#80]
- Remove base button does nothing [\#72]
- Attempted double use of PCI Address [\#71]
- At /machines there is a request for {{machine.id}}.png [\#68]
- Attempted double use of PCI Address [\#71]
- Domains won't start if host IP changes [\#84]
- Make clone volumes unique [\#87]
- Clones of clones crash at start with apparmor error DENIED [\#90]
- Prepare base doesn't send a message when done [\#91]
- Duplicate USB controllers with index 0 [\#99]
- Check USB redirection [\#101]
- The backend dies when mysql is down [\#102]
- message/read/"id".json calls doesnt mark message as read. [\#104]
- When user is logged and fails login form the frontend fails [\#73]
- When user gets logged out it gets access denied [\#76]
- two requests for start try to use open iptables [\#81]
- Skip tests when no VMs available [\#63]
- review KVM add volume [\#95]
- Test failed, prepare failed near "100": syntax error at User.pm [\#106]
This diff is collapsed.
use strict;
use warnings;
use ExtUtils::MakeMaker;
WriteMakefile(
VERSION => '0.01',
PREREQ_PM => {
'Mojolicious' => '6.15'
,'DBIx::Connector' => 0
,'Authen::Passphrase' => 0
,'IPC::Run3' => 0
,'JSON::XS' => 0
,'Moose' => 0
,'Net::LDAP' => 0
,'Sys::Virt' => 0
,'XML::LibXML'=> 0
,'YAML' => 0
,'Image::Magick' => 0
,'MooseX::Types::NetAddr::IP' => 0
,'IO::Interface' => 0
,'Sys::Statistics::Linux' => 0
,'Test::Pod::Coverage' => 0
,'Locale::Maketext::Lexicon' => 0
,'Mojolicious::Plugin::I18N' => 0
},
TEST_REQUIRES => {
'Test::SQL::Data' => 0
},
test => {TESTS => 't/*.t t/*/*.t'},
clean => {FILES => 't/.db' }
);
# ravada [![GitHub version](https://img.shields.io/badge/version-0.1.1--beta-brightgreen.svg)](https://github.com/frankiejol/ravada/releases) [![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://github.com/frankiejol/ravada/blob/master/LICENSE)
Remove Virtual Desktops Manager
Broker: ravada
Hypervisors: [KVM](http://www.linux-kvm.org/) - [LXC](https://linuxcontainers.org/)
Remote Access: [Spice](http://www.spice-space.org/)
## Install
Read [docs/INSTALL.md](https://github.com/frankiejol/ravada/blob/master/docs/INSTALL.md)
Connect to the server with a web browser at http://servername:3000/
### Production
See [docs/production.md](https://github.com/frankiejol/ravada/blob/master/docs/production.md)
### Operation
See [docs/operation.md](https://github.com/frankiejol/ravada/blob/master/docs/operation.md)
### Testing
See [docs/test.md](https://github.com/frankiejol/ravada/blob/master/docs/test.md)
#!/usr/bin/perl
use warnings;
use strict;
use lib './lib';
use Getopt::Long;
use Proc::PID::File;
use Ravada;
use Ravada::Auth::SQL;
use Ravada::Auth::LDAP;
my $help;
my ($DEBUG, $ADD_USER );
my $FILE_CONFIG = "/etc/ravada.conf";
my $ADD_USER_LDAP;
my $IMPORT_DOMAIN;
my $CHANGE_PASSWORD;
my $NOFORK;
my $USAGE = "$0 "
." [--debug] [--file-config=$FILE_CONFIG] [--add-user=name] [--add-user-ldap=name]"
." [--change-password]"
." [-X] [start|stop|status]"
."\n"
." --add-user : adds a new db user\n"
." --add-user-ldap : adds a new LDAP user\n"
." --change-password : changes the password of an user\n"
." --import-domain : import a domain\n"
." -X : start in foreground\n"
;
GetOptions ( help => \$help
,debug => \$DEBUG
,'no-fork'=> \$NOFORK
,'config=s'=> \$FILE_CONFIG
,'add-user=s'=> \$ADD_USER
,'change-password'=> \$CHANGE_PASSWORD
,'add-user-ldap=s'=> \$ADD_USER_LDAP
,'import-domain=s' => \$IMPORT_DOMAIN
) or exit;
#####################################################################
#
# check arguments
#
if ($help) {
print $USAGE;
exit;
}
die "Only root can do that\n" if $> && ( $ADD_USER || $ADD_USER_LDAP || $IMPORT_DOMAIN);
$Ravada::DEBUG=1 if $DEBUG;
$Ravada::CAN_FORK=0 if $NOFORK;
###################################################################
my $PID_LONGS;
###################################################################
#
sub do_start {
warn "Starting rvd_back\n";
my $old_error = ($@ or '');
my $cnt_error = 0;
clean_killed_requests();
start_process_longs() if !$NOFORK;
my $ravada = Ravada->new( config => $FILE_CONFIG );
for (;;) {
my $t0 = time;
$ravada->process_requests();
$ravada->process_long_requests(0,$NOFORK) if $NOFORK;
sleep 1 if time - $t0 <1;
}
}
sub start_process_longs {
my $pid = fork();
die "I can't fork" if !defined $pid;
if ( $pid ) {
$PID_LONGS = $pid;
return;
}
warn "Processing long requests in pid $$\n" if $DEBUG;
my $ravada = Ravada->new( config => $FILE_CONFIG );
for (;;) {
my $t0 = time;
$ravada->process_long_requests();
sleep 1 if time - $t0 <1;
}
}
sub clean_killed_requests {
my $ravada = Ravada->new( config => $FILE_CONFIG );
$ravada->clean_killed_requests();
}
sub start {
{
my $ravada = Ravada->new( config => $FILE_CONFIG );
$Ravada::CONNECTOR->dbh;
}
for (;;) {
my $pid = fork();
die "I can't fork $!" if !defined $pid;
if ($pid == 0 ) {
do_start();
exit;
}
warn "Waiting for pid $pid\n";
waitpid($pid,0);
}
}
sub add_user {
my $login = shift;
print "$login password: ";
my $password = <STDIN>;
chomp $password;
print "is admin ? : [y/n] ";
my $is_admin_q = <STDIN>;
my $is_admin = 0;
$is_admin = 1 if $is_admin_q =~ /y/i;
Ravada::Auth::SQL::add_user( name => $login
, password => $password
, is_admin => $is_admin);
}
sub add_user_ldap {
my $login = shift;
print "password : ";
my $password = <STDIN>;
chomp $password;
Ravada::Auth::LDAP::add_user($login, $password);
}
sub change_password {
print "User login name : ";
my $login = <STDIN>;
chomp $login;
return if !$login;
my $user = Ravada::Auth::SQL->new(name => $login);
die "ERROR: Unknown user '$login'\n" if !$user->id;
print "password : ";
my $password = <STDIN>;
chomp $password;
$user->change_password($password);
}
sub import_domain {
my $name = shift;
print "Virtual Manager: KVM\n";
print "User name : ";
my $user = <STDIN>;
chomp $user;
my $ravada = Ravada->new( config => $FILE_CONFIG );
$ravada->import_domain(name => $name, vm => 'KVM', user => $user);
}
sub DESTROY {
return if !$PID_LONGS;
warn "Killing pid: $PID_LONGS";
my $cnt = kill 15 , $PID_LONGS;
return if !$cnt;
kill 9 , $PID_LONGS;
}
#################################################################
if ($ADD_USER) {
add_user($ADD_USER);
exit;
} elsif ($ADD_USER_LDAP) {
add_user($ADD_USER_LDAP);
exit;
} elsif ($CHANGE_PASSWORD) {
change_password();
exit;
} elsif ($IMPORT_DOMAIN) {
import_domain($IMPORT_DOMAIN);
exit;
}
die "Already started" if Proc::PID::File->running();
start();
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: ravada
Upstream-Contact: Francesc Guasch <frankie@telecos.upc.edu>
Source: https://github.com/frankiejol/ravada
Files: *
Copyright: 2017 UPC
License: GPL-3
On Debian systems, the complete text of the GNU General
Public License version 3 can be found in `/usr/share/common-licenses/GPL-3'.
#!/usr/bin/perl
use warnings;
use strict;
use File::Path qw(remove_tree make_path);
use IPC::Run3;
use lib './lib';
use Ravada;
use File::Copy;
my $DIR_SRC = "pkg-debian";
my $RELEASE = Ravada::version();
my $DIR_DST = "ravada-$RELEASE";
my %DIR = (
templates => '/usr/share/ravada'
,'etc/ravada.conf' => 'etc'
,'etc/xml' => 'var/lib/ravada'
,'docs/' => 'usr/share/doc/ravada'
,sql => 'usr/share/doc/ravada'
,'lib/' => 'usr/share/perl5'
,'blib/man3' => 'usr/share/man'
,"$DIR_SRC/" => "./"
);
for ( qw(css fonts img js templates)) {
$DIR{"public/$_"} = "usr/share/ravada/public";
}
my %FILE = (
'etc/rvd_front.conf.example' => 'etc/rvd_front.conf'
,'bin/rvd_back.pl' => 'usr/sbin/rvd_back'
,'rvd_front.pl' => 'usr/sbin/rvd_front'
,'CHANGELOG.md' => 'usr/share/doc/ravada/changelog'
,'copyright' => 'usr/share/doc/ravada'
);
my @REMOVE= qw(
usr/share/doc/ravada/_config.yml
usr/share/doc/ravada/INSTALL.md
usr/share/ravada/templates/bootstrap/get_authors.sh
usr/share/man/man3/.exists
);
########################################################################
sub clean {
remove_tree($DIR_DST);
}
sub copy_dirs {
for my $src (sort keys %DIR) {
my $dst = "$DIR_DST/$DIR{$src}";
make_path($dst) if ! -e $dst;
my ($in, $out, $err);
my @cmd = ('rsync','-avL',$src,$dst);
run3(\@cmd, \$in, \$out, \$err);
die $err if $err;
print `chmod go+rx $dst`;
}
}
sub copy_files {
for my $src (keys %FILE) {
my $dst = "$DIR_DST/$FILE{$src}";
my ($dir) = $dst =~ m{(.*)/.*};
make_path($dir) if !-d $dir;
mkdir $dst if $dst =~ m{.*/$} && ! -e $dst;
copy($src,$dst) or die "$! $src -> $dst";
}
}
sub remove_not_needed {
for my $file (@REMOVE) {
$file = "$DIR_DST/$file";
unlink $file or die "$! $file";
}
for my $dir ('usr/share/doc/ravada/sql/sqlite') {
my $path = "$DIR_DST/$dir";
die "Missing $path" if ! -e $path;
remove_tree($path);
}
}
sub create_md5sums {
my @files;
chdir $DIR_DST or die "I can't chdir to $DIR_DST";
unlink "DEBIAN/md5sums";
open my $find, ,'-|', 'find . -type f -printf \'%P\n\'' or die $!;
while (<$find>) {
chomp;
next if /^DEBIAN/;
print `md5sum $_ >> DEBIAN/md5sums`
}
close $find;
chdir "..";
chmod 0644,"$DIR_DST/DEBIAN/md5sums" or die $!;
}
sub create_deb {
# my $deb = "ravada_${RELEASE}_all.deb";
# my @cmd = ('dpkg','-b',"$DIR_DST/",$deb);
chdir $DIR_DST or die "$! $DIR_DST";
my @cmd = ('debuild','-us','-uc');
my ($in, $out, $err);
run3(\@cmd, \$in, \$out, \$err);
die $err if $err;
print $out;
}
sub remove_use_lib {
for my $file ('usr/sbin/rvd_front','usr/sbin/rvd_back') {
my $path = "$DIR_DST/$file";
die "Missing file '$path'" if ! -e $path;
copy($path, "$path.old") or die "$! $path -> $path.old";
open my $in,'<',"$path.old" or die "$! $path.old";
open my $out,'>',$path or die "$! $path";
while (<$in>) {
next if /^use lib/;
print $out $_;
}
close $out;
close $in;
unlink "$path.old" or die "$! $path.old";
chmod 0755,$path or die "$! chmod 755 $path";
}
}
sub change_mod {
for my $file ( 'rvd_front.service', 'rvd_back.service') {
my $path = "$DIR_DST/lib/systemd/system/$file";
chmod 0644,$path or die "$! $path";
}
}
sub gzip_docs {
for my $file ( 'changelog' ) {
my $path = "$DIR_DST/usr/share/doc/ravada/$file";
die "Missing $path\n"
if !-e $path;
print `gzip -n -9 $path`;
}
}
sub gzip_man {
my $dir = "$DIR_DST/usr/share/man/man3" ;
opendir my $ls,$dir or die "$! $dir";
while ( my $file = readdir $ls ) {
next if ! -f "$dir/$file";
print `gzip -n -9 $dir/$file`;
}
closedir $ls;
}
sub chown_files {
my $dir = shift;
my $file_perm = ( shift or 0644);
my $dir_perm = (shift or 0755);
my $deb_dir = "$DIR_DST/$dir";
chmod($dir_perm,$deb_dir) or die "$! $deb_dir";
chown(0,0,$deb_dir) or die "$! $deb_dir";
return if ! -d $deb_dir;
opendir my $ls,$deb_dir or die "$! $deb_dir";
while (my $file = readdir $ls) {
next if $file =~ m{^\.};
my $path = "$deb_dir/$file";
die "Missing $path" if ! -e $path;
chown(0,0,$path) or die "$! $path";
if ( -f $path ) {
chmod ($file_perm, $path) or die "$! $path";
# printf("chmod %o $path\n",$file_perm);
}
chown_files("$dir/$file") if -d $path;
}
closedir $ls;
}
sub chown_pms {
print `find $DIR_DST/ -iname "*pm" -exec chmod 755 {} \\;`;
print `find $DIR_DST/usr/share -iname "*po" -exec chmod 755 {} \\;`;
}
sub chmod_control_files {
for (qw(conffiles templates)) {
my $path = "$DIR_DST/DEBIAN/$_";
die "Missing $path" if ! -e $path;
chmod 0644 , $path or die "$! $path";
}
}
sub chmod_ravada_conf {
chmod 0600,"$DIR_DST/etc/ravada.conf" or die $!;
}
#########################################################################
clean();
copy_dirs();
copy_files();
remove_not_needed();
change_mod();
gzip_docs();
gzip_man();
chown_files('DEBIAN',0755);
#chown_files('usr/share/doc/ravada');
#chown_files('usr/share/ravada/public');
#chown_files('usr/share/ravada/templates');
chown_files('etc');
chown_files('lib');
#chown_files('lib/systemd');
chown_files('var/lib/ravada');
#chown_files('usr/share/perl5');
#chown_files('usr/share/man');
chown_files('usr');
chown_files('var');
remove_use_lib();
chmod_control_files();
chmod_ravada_conf();
#chown_pms();
create_md5sums();
create_deb();
ravada for Debian
----------------
<possible notes regarding this package - if none, delete this file>
-- Francesc Guasch <frankie@telecos.upc.edu> Wed, 15 Mar 2017 20:24:20 +0100
ravada for Debian
----------------
<this file describes information about the source package, see Debian policy
manual section 4.14. You WILL either need to modify or delete this file>
-- Francesc Guasch <frankie@telecos.upc.edu> Wed, 15 Mar 2017 20:24:20 +0100
ravada (0.1.2-1) unstable; urgency=medium
* Initial release (Closes: #nnnn) <nnnn is the bug number of your ITP>
-- Francesc Guasch <frankie@telecos.upc.edu> Wed, 15 Mar 2017 20:24:20 +0100
Source: ravada
Section: unknown
Priority: optional
Maintainer: Francesc Guasch <frankie@telecos.upc.edu>
Build-Depends: debhelper (>=9)
Standards-Version: 3.9.8
Homepage: <insert the upstream URL, if relevant>
#Vcs-Git: git://anonscm.debian.org/collab-maint/ravada.git
#Vcs-Browser: https://anonscm.debian.org/cgit/collab-maint/ravada.git
Package: ravada
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: <insert up to 60 chars description>
<insert long description, indented with spaces>
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: ravada
Source: <url://example.com>
Files: *
Copyright: <years> <put author's name and email here>
<years> <likewise for another author>
License: GPL-3.0+
Files: debian/*
Copyright: 2017 Francesc Guasch <frankie@telecos.upc.edu>
License: GPL-3.0+