From b893de76d0f2674f02421bc451e2f6708fb8219e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= Date: Tue, 19 Nov 2024 10:19:42 +0100 Subject: [PATCH] Cleanup and remove systemd use in the setup scripts Remove unused code in the setup scripts in order to ease refactoring them. This commit removes the need for systemd running as PID1 to run the setup script. This also means that mgr-setup has to be called before running the real container and starting everything. Note that some of the cleanup removing non-SUSE distributions handling, which shouldn't be a problem as Uyuni is now only shipped as a container built on a single openSUSE distro. --- .../perl-Satcon/bin/satcon-deploy-tree.pl | 2 - ...l-Satcon.changes.cbosdo.systemd-free-setup | 1 + rel-eng/packages/spacewalk-setup-postgresql | 1 - schema/spacewalk/spacewalk-schema-upgrade | 5 +- ...r-schema.changes.cbosdo.systemd-free-setup | 1 + spacewalk/admin/Makefile.admin | 1 - spacewalk/admin/rhn-config-schema.pl | 192 ------- ...lk-admin.changes.cbosdo.systemd-free-setup | 1 + spacewalk/admin/spacewalk-admin.spec | 3 - ...pacewalk.changes.cbosdo.systemd-free-setup | 1 + spacewalk/package/spacewalk.spec | 15 - .../setup/bin/spacewalk-make-mount-points | 92 ---- spacewalk/setup/bin/spacewalk-setup | 219 +------- spacewalk/setup/lib/Spacewalk/Setup.pm | 472 ++---------------- .../setup/share/defaults.d/defaults.conf | 141 ------ ...lk-setup.changes.cbosdo.systemd-free-setup | 1 + spacewalk/setup/spacewalk-setup.spec | 5 - spacewalk/spacewalk-setup-postgresql/LICENSE | 339 ------------- .../bin/spacewalk-setup-postgresql | 425 ---------------- .../setup/defaults.d/embedded-postgresql.conf | 5 - .../setup/postgresql.conf | 12 - .../spacewalk-setup-postgresql.changes | 191 ------- .../spacewalk-setup-postgresql.spec | 75 --- .../bin/uyuni-setup-reportdb | 64 +-- ...reportdb.changes.cbosdo.systemd-free-setup | 1 + .../docker/scripts/reset_pgsql_database.sh | 2 +- .../schema_migration_reportdb_test_pgsql.sh | 2 +- .../scripts/schema_migration_test_pgsql.sh | 2 +- susemanager/bin/mgr-setup | 115 +---- ...emanager.changes.cbosdo.systemd-free-setup | 1 + 30 files changed, 103 insertions(+), 2284 deletions(-) create mode 100644 projects/perl-Satcon/perl-Satcon.changes.cbosdo.systemd-free-setup delete mode 100644 rel-eng/packages/spacewalk-setup-postgresql create mode 100644 schema/spacewalk/susemanager-schema.changes.cbosdo.systemd-free-setup delete mode 100755 spacewalk/admin/rhn-config-schema.pl create mode 100644 spacewalk/admin/spacewalk-admin.changes.cbosdo.systemd-free-setup create mode 100644 spacewalk/package/spacewalk.changes.cbosdo.systemd-free-setup delete mode 100755 spacewalk/setup/bin/spacewalk-make-mount-points delete mode 100644 spacewalk/setup/share/defaults.d/defaults.conf create mode 100644 spacewalk/setup/spacewalk-setup.changes.cbosdo.systemd-free-setup delete mode 100644 spacewalk/spacewalk-setup-postgresql/LICENSE delete mode 100755 spacewalk/spacewalk-setup-postgresql/bin/spacewalk-setup-postgresql delete mode 100644 spacewalk/spacewalk-setup-postgresql/setup/defaults.d/embedded-postgresql.conf delete mode 100644 spacewalk/spacewalk-setup-postgresql/setup/postgresql.conf delete mode 100644 spacewalk/spacewalk-setup-postgresql/spacewalk-setup-postgresql.changes delete mode 100644 spacewalk/spacewalk-setup-postgresql/spacewalk-setup-postgresql.spec create mode 100644 spacewalk/uyuni-setup-reportdb/uyuni-setup-reportdb.changes.cbosdo.systemd-free-setup create mode 100644 susemanager/susemanager.changes.cbosdo.systemd-free-setup diff --git a/projects/perl-Satcon/bin/satcon-deploy-tree.pl b/projects/perl-Satcon/bin/satcon-deploy-tree.pl index 3ae20bce55e2..69ac936d86c7 100755 --- a/projects/perl-Satcon/bin/satcon-deploy-tree.pl +++ b/projects/perl-Satcon/bin/satcon-deploy-tree.pl @@ -94,8 +94,6 @@ sub process_file { my $apache_group = getgrnam(`grep -hsoP "(?<=Group ).*" /etc/httpd/conf/*.conf /etc/apache2/*.conf | tr -d '\n'`); chown 0, $apache_group, "$destdir/$relative_path"; - system '/sbin/restorecon', '-vv', "$destdir/$relative_path"; - while () { my $out = $engine->perform_substitutions($_); print OF $out; diff --git a/projects/perl-Satcon/perl-Satcon.changes.cbosdo.systemd-free-setup b/projects/perl-Satcon/perl-Satcon.changes.cbosdo.systemd-free-setup new file mode 100644 index 000000000000..21dcba8f3728 --- /dev/null +++ b/projects/perl-Satcon/perl-Satcon.changes.cbosdo.systemd-free-setup @@ -0,0 +1 @@ +- Remove useless selinux-related code diff --git a/rel-eng/packages/spacewalk-setup-postgresql b/rel-eng/packages/spacewalk-setup-postgresql deleted file mode 100644 index 7f8512a13f4f..000000000000 --- a/rel-eng/packages/spacewalk-setup-postgresql +++ /dev/null @@ -1 +0,0 @@ -5.1.1-0 spacewalk/spacewalk-setup-postgresql/ diff --git a/schema/spacewalk/spacewalk-schema-upgrade b/schema/spacewalk/spacewalk-schema-upgrade index 7ea8a6fbd28a..5e92dcc8f27c 100755 --- a/schema/spacewalk/spacewalk-schema-upgrade +++ b/schema/spacewalk/spacewalk-schema-upgrade @@ -106,10 +106,7 @@ elsif($server_version > $MAX_PG_DB_VERSION) { exit 1; } -my $my_schema_version_out = `rpm -qf --qf '%{name} %{version} %{release}\n' $SCHEMA_DIR/schema-override 2> /dev/null`; -if ($?) { # the directory does not exists or is not owned by any rpm - $my_schema_version_out = `rpm -qf --qf '%{name} %{version} %{release}\n' $SCHEMA_DIR/main.sql`; -} +$my_schema_version_out = `rpm -qf --qf '%{name} %{version} %{release}\n' $SCHEMA_DIR/main.sql`; my ($my_schema_name, $my_schema_version, $my_schema_release) = ($my_schema_version_out =~ /^(\S+)\s(\S+)\s(\S+)$/); if (not defined $my_schema_release) { die "Failed to retrieve our schema package name and version.\n"; diff --git a/schema/spacewalk/susemanager-schema.changes.cbosdo.systemd-free-setup b/schema/spacewalk/susemanager-schema.changes.cbosdo.systemd-free-setup new file mode 100644 index 000000000000..2ec9cc1ef5f2 --- /dev/null +++ b/schema/spacewalk/susemanager-schema.changes.cbosdo.systemd-free-setup @@ -0,0 +1 @@ +- Clean up code related to unused schema-override diff --git a/spacewalk/admin/Makefile.admin b/spacewalk/admin/Makefile.admin index 7ddc5c3df113..6db16ebfa15e 100644 --- a/spacewalk/admin/Makefile.admin +++ b/spacewalk/admin/Makefile.admin @@ -30,7 +30,6 @@ CONF_DEST = $(PREFIX)/$(CONFDIR) SYSTEMD_DEST = $(PREFIX)/$(SYSTEMDDIR) SCRIPTS = rhn-config-satellite.pl \ - rhn-config-schema.pl \ rhn-deploy-ca-cert.pl \ rhn-install-ssl-cert.pl \ salt-secrets-config.py diff --git a/spacewalk/admin/rhn-config-schema.pl b/spacewalk/admin/rhn-config-schema.pl deleted file mode 100755 index 0fe97d04b146..000000000000 --- a/spacewalk/admin/rhn-config-schema.pl +++ /dev/null @@ -1,192 +0,0 @@ -#!/usr/bin/perl -# -# Copyright (c) 2008--2015 Red Hat, Inc. -# -# This software is licensed to you under the GNU General Public License, -# version 2 (GPLv2). There is NO WARRANTY for this software, express or -# implied, including the implied warranties of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 -# along with this software; if not, see -# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. -# -# Red Hat trademarks are not licensed under GPLv2. No permission is -# granted to use or replicate Red Hat trademarks that are incorporated -# in this software or its documentation. -# -# - -use strict; -use warnings; - -use Getopt::Long; -use English; - -$ENV{PATH} = '/bin:/usr/bin'; - -my $usage = "usage: $0 --source= --target= " - . "--tablespace-name= [ --help ]\n"; - -my $source = ''; -my $target = ''; -my $tablespace_name = ''; -my $help = ''; - -GetOptions("source=s" => \$source, "target=s" => \$target, - "tablespace-name=s" => \$tablespace_name, "help" => \$help) or die $usage; - -if ($help or not ($source and $target and $tablespace_name)) { - die $usage; -} - -my $backend = 'oracle'; -if ($source =~ m!/postgres(ql)?/!) { - $backend = 'postgresql'; -} - -open(SOURCE, "< $source") or die "Could not open $source: $OS_ERROR"; -open(TARGET, "> $target") or die "Could not open $target for writing: $OS_ERROR"; - -my $subdir_name = 'schema-override'; -my $exception_dir; -($exception_dir = $source) =~ s!/[^/]+$!/$subdir_name!; - -my %exception_files; -my @exception_queue = ( '' ); -while (@exception_queue) { - my $d = shift @exception_queue; - if ($d ne '') { - $d .= '/'; - } - my $full_path = "$exception_dir/$d"; - if (-d $full_path) { - if (opendir DIR, $full_path) { - for (sort readdir DIR) { - next if /^\.\.?$/; - if (-d "$full_path$_") { - push @exception_queue, "$d$_"; - } else { - $exception_files{"$d$_"} = 1; - } - } - closedir DIR; - } - } -} - -my $marker_re = qr/^-- Source: (.+?)$|^select '(.+?)' sql_file from dual;$/; -my $line; - -my %exception_seen; -while ($line = ) { - if ($line =~ $marker_re) { - my $filename = $1; - if (not defined $filename) { - $filename = $2; - $filename =~ s!^.+/([^/]+/[^/]+)$!$1!; - } - my $full_file = undef; - if (exists $exception_files{"$filename.$backend"}) { - $full_file = "$exception_dir/$filename.$backend"; - } elsif (exists $exception_files{$filename}) { - $full_file = "$exception_dir/$filename"; - } - if (defined $full_file) { - for my $e ( '', '.oracle', '.postgresql' ) { - $exception_seen{"$filename$e"}++ if exists $exception_files{"$filename$e"}; - } - open OVERRIDE, $full_file or die "Error reading file [$full_file]: $!\n"; - print TARGET "-- Source: $subdir_name/$filename\n\n"; - while () { - s/\[\[.*\]\]/$tablespace_name/g; - s/__.*__/$tablespace_name/g; - print TARGET $_; - } - close OVERRIDE; - while ($line = ) { - if ($line =~ $marker_re) { - last; - } - } - print TARGET "\n"; - redo; - } - } - $line =~ s/\[\[.*\]\]/$tablespace_name/g; - $line =~ s/__.*__/$tablespace_name/g; - - print TARGET $line; -} - -close(SOURCE); -close(TARGET); - -my $error = 0; -for (sort keys %exception_seen) { - if ($exception_seen{$_} > 1) { - warn "Schema source [$source] loaded override [$_] more than once.\n"; - $error = 1; - } -} -for (sort keys %exception_files) { - if (not exists $exception_seen{$_}) { - warn "Schema source [$source] did not use override [$_].\n"; - $error = 1; - } -} - -system('/usr/sbin/selinuxenabled'); -if ($? >> 8 == 0) { - if (-x '/usr/sbin/restorecon') { - system('/usr/sbin/restorecon', '-F', $target); - } elsif (-x '/sbin/restorecon') { - system('/sbin/restorecon', '-F', $target); - } -} - -exit $error; - -=pod - -=head1 NAME - -rhn-config-schema.pl - utility to populate Spacewalk database tablespacee. - -=head2 SYNOPSIS - -B B<--source=SOURCE> B<--target=TARGET> B<--tablespace-name=TABLESPACE> - -B [B<--help>] - -=head1 DESCRIPTION - -This script is intended to run from inside of B. You do not want to run -it directly unless you really knows what are you doing. - -=head1 OPTIONS - -=over 5 - -=item B<--source=SOURCE> - -Full path to main.sql file. Usually /usr/share/susemanager/db/I/main.sql - -=item B<--target=TARGET> - -Full path to deploy.sql. Usually /usr/share/susemanager/db/I/deploy.sql - -=item B<--tablespace-name=TABLESPACE> - -Which tablespace will be populated. This does nothing with database itself, -this script just substitute template variables with given value of I. - -=item B<--help> - -Display allowed parameters. - -=back - -=head1 SEE ALSO - -B(8), B(8), B(8) - -=cut diff --git a/spacewalk/admin/spacewalk-admin.changes.cbosdo.systemd-free-setup b/spacewalk/admin/spacewalk-admin.changes.cbosdo.systemd-free-setup new file mode 100644 index 000000000000..8655db3c0143 --- /dev/null +++ b/spacewalk/admin/spacewalk-admin.changes.cbosdo.systemd-free-setup @@ -0,0 +1 @@ +- Remove useless selinux and oracle related code diff --git a/spacewalk/admin/spacewalk-admin.spec b/spacewalk/admin/spacewalk-admin.spec index 91a08e0918d7..b591d6199420 100644 --- a/spacewalk/admin/spacewalk-admin.spec +++ b/spacewalk/admin/spacewalk-admin.spec @@ -61,7 +61,6 @@ sed -i 's/apache2.service/httpd.service/g' uyuni-check-database.service make -f Makefile.admin install PREFIX=%{buildroot} mkdir -p %{buildroot}%{_mandir}/man8/ -%{_bindir}/pod2man --section=8 rhn-config-schema.pl > %{buildroot}%{_mandir}/man8/rhn-config-schema.pl.8 %{_bindir}/pod2man --section=8 man/spacewalk-service.pod > %{buildroot}%{_mandir}/man8/spacewalk-service.8 %{_bindir}/pod2man --section=8 man/rhn-sat-restart-silent.pod > %{buildroot}%{_mandir}/man8/rhn-sat-restart-silent.8 %{_bindir}/pod2man --section=8 rhn-config-satellite.pl > %{buildroot}%{_mandir}/man8/rhn-config-satellite.pl.8 @@ -81,13 +80,11 @@ fi %{_sbindir}/uyuni-update-config %{_sbindir}/import-suma-build-keys %{_bindir}/rhn-config-satellite.pl -%{_bindir}/rhn-config-schema.pl %{_bindir}/rhn-deploy-ca-cert.pl %{_bindir}/rhn-install-ssl-cert.pl %{_bindir}/salt-secrets-config.py %{_sbindir}/rhn-sat-restart-silent %{_sbindir}/mgr-monitoring-ctl -%{_mandir}/man8/rhn-config-schema.pl.8* %{_mandir}/man8/spacewalk-service.8* %{_mandir}/man8/rhn-sat-restart-silent.8* %{_mandir}/man8/rhn-config-satellite.pl.8* diff --git a/spacewalk/package/spacewalk.changes.cbosdo.systemd-free-setup b/spacewalk/package/spacewalk.changes.cbosdo.systemd-free-setup new file mode 100644 index 000000000000..cf120c84b108 --- /dev/null +++ b/spacewalk/package/spacewalk.changes.cbosdo.systemd-free-setup @@ -0,0 +1 @@ +- Remove unused configuration defaults files diff --git a/spacewalk/package/spacewalk.spec b/spacewalk/package/spacewalk.spec index 1d2c758cfb49..92bac9bc1334 100644 --- a/spacewalk/package/spacewalk.spec +++ b/spacewalk/package/spacewalk.spec @@ -135,15 +135,7 @@ Version for PostgreSQL database backend. #nothing to do here %install -RDBMS="postgresql" install -d %{buildroot}%{_sysconfdir} -install -d %{buildroot}%{_datadir}/spacewalk/setup/defaults.d -for i in ${RDBMS} ; do - cat <%{buildroot}%{_datadir}/spacewalk/setup/defaults.d/$i-backend.conf -# database backend to be used by spacewalk -db-backend = $i -EOF -done install -d %{buildroot}%{_bindir} %if 0%{?rhel} ln -s %{_prefix}/pgsql-14/bin/initdb %{buildroot}%{_bindir}/initdb @@ -155,13 +147,6 @@ ln -s %{_prefix}/pgsql-14/bin/initdb %{buildroot}%{_bindir}/initdb %if 0%{?suse_version} %dir %{_datadir}/spacewalk %dir %{_datadir}/spacewalk/setup -%dir %{_datadir}/spacewalk/setup/defaults.d -%endif - -%files postgresql -%{_datadir}/spacewalk/setup/defaults.d/postgresql-backend.conf -%if 0%{?rhel} -%{_bindir}/initdb %endif %changelog diff --git a/spacewalk/setup/bin/spacewalk-make-mount-points b/spacewalk/setup/bin/spacewalk-make-mount-points deleted file mode 100755 index 43e50f31f861..000000000000 --- a/spacewalk/setup/bin/spacewalk-make-mount-points +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/perl - -# Given a list of directories (for example, /var/satellite) -# check if they exist and if they do not exist, create them -# with apache as owner. Also run restorecon on them, and -# if they are nfs_t mounted, set spacewalk_nfs_mountpoint boolean. - -use strict; -use warnings FATAL => 'all'; - -use Spacewalk::Setup (); - -my %dirs; -@dirs{@ARGV} = (); - -# Add both potential Apache group IDs (SUSE/RHEL) -my $apache_uid = (getpwnam('wwwrun') // "") . (getpwnam('apache') // ""); -if ($apache_uid eq "" ) { - die "Failed to retrieve uid of user apache, the user does not seem to exist.\n"; -} -my $seen_nfs = 0; -for my $dir (sort { length $a <=> length $b } keys %dirs) { - if (not -e $dir) { - my @parts = grep { $_ ne '' } split /\//, $dir; - my $path = ''; - for my $p (@parts) { - $path .= "/$p"; - if (not -e $path) { - mkdir $path, 0755 or die "Error creating directory [$path]: $!\n"; - } - } - } - chown $apache_uid, -1, $dir or die "Error chowning dir [$dir] to [wwwrun]: $!\n"; - my @paths = $dir; - if (-l $paths[0]) { - # if the path is a symlink, we will try to restorecon - # the target as well - push @paths, "$paths[0]/."; - } - if (Spacewalk::Setup::have_selinux()) { - for my $path (@paths) { - my $type = `ls -d -Z -- $path`; - if (defined $type - and $type =~ /^.+?:.+?:(.+?)(:|\s)/ - and $1 eq 'nfs_t') { - $seen_nfs = 1; - } else { - if (Spacewalk::Setup::have_selinux()) { - system('/sbin/restorecon', '-r', $path); - } - } - } - } -} -if ($seen_nfs and Spacewalk::Setup::have_selinux()) { - system('/usr/sbin/setsebool', '-P', 'spacewalk_nfs_mountpoint', 1); - system('/usr/sbin/setsebool', '-P', 'cobbler_use_nfs', 1); -} - -exit 0; - -=pod - -=head1 NAME - -spacewalk-make-mount-points - prepare directories for Spacewalk - -=head1 SYNOPSIS - -spacewalk-make-mount-points [DIR1 [DIR2 ...]] - -=head1 DESCRIPTION - -Given a list of directories (for example, /var/satellite) this -script will check if directories exist and if they do not exist, -create them with apache as owner. Also run restorecon on them, -and if they are nfs_t mounted, set spacewalk_nfs_mountpoint -boolean. - -This script is not intended to be run directly by human. -spacewalk-setup use this script internally. - -=head1 SEE ALSO - -spacewalk-setup(8) - -=head1 COPYRIGHT AND LICENSE - -Copyright (c) 2011--2015 Red Hat, Inc. -Released under GNU General Public License, version 2 (GPLv2). - -=cut diff --git a/spacewalk/setup/bin/spacewalk-setup b/spacewalk/setup/bin/spacewalk-setup index c98f2d401219..0fbf2b9f5df2 100755 --- a/spacewalk/setup/bin/spacewalk-setup +++ b/spacewalk/setup/bin/spacewalk-setup @@ -44,15 +44,11 @@ $|++; use constant DEFAULT_CA_CERT_NAME => 'RHN-ORG-TRUSTED-SSL-CERT'; -use constant COBBLER_COMMAND => 'spacewalk-setup-cobbler'; - my %opts = Spacewalk::Setup::parse_options(); my %answers = (); $answers{'db-backend'} = 'postgresql'; # the only supported currently my @skip = (); -push @skip, Spacewalk::Setup::EMBEDDED_DB_ANSWERS - if not Spacewalk::Setup::is_embedded_db(\%opts); Spacewalk::Setup::load_answer_file(\%opts, \%answers, \@skip); my $product_name = $answers{'product_name'} || 'Spacewalk'; @@ -69,25 +65,7 @@ if (not defined $opts{"clear-db"} and defined $answers{"clear-db"} and $opts{'clear-db'} = 1; } -$opts{"skip-db-install"} = 1 if $opts{"clear-db"}; - -# Skip the logfile init, normally just used when called from install.pl, -# which already did this. -if (not $opts{"skip-logfile-init"}) { - Spacewalk::Setup::init_log_files($product_name, @ARGV); -} - -if (Spacewalk::Setup::have_selinux()) { - print Spacewalk::Setup::loc("* Setting up SELinux..\n"); - Spacewalk::Setup::system_or_exit(['/usr/sbin/spacewalk-selinux-enable', ''], 42, - 'Could not enable selinux policy.'); -} - -if ($opts{"run-cobbler"}) { - print Spacewalk::Setup::loc("* Setting up Cobbler..\n"); - setup_cobbler(\%opts, \%answers); - exit 0; -} +Spacewalk::Setup::init_log_files($product_name, @ARGV); my %rhnOptions = (); if (-e Spacewalk::Setup::DEFAULT_RHN_CONF_LOCATION) { @@ -105,9 +83,6 @@ if ($opts{'db-only'}) { exit; } -remove_old_jvm(\%opts, \%answers); -remove_tomcat_cache(\%opts); - setup_services(); setup_admin_email(\%opts, \%answers, \%rhnOptions); @@ -115,14 +90,14 @@ setup_admin_email(\%opts, \%answers, \%rhnOptions); if(not $opts{"skip-initial-configuration"}) { print Spacewalk::Setup::loc("* Performing initial configuration.\n"); my $config_opts = populate_initial_configs(\%opts, \%answers); - mkdir_mount_points($config_opts->{'mount_point'}, - $config_opts->{'mount_point'} . '/packages', - $config_opts->{'mount_point'} . '/systems', - $config_opts->{'kickstart_mount_point'}); + my $www_uid = (getpwnam('wwwrun') // ""); + chown $www_uid, -1, $config_opts->{'mount_point'} . '/packages'; + chmod 0775, $config_opts->{'mount_point'}; chmod 0775, $config_opts->{'mount_point'} . '/systems'; + chmod 0775, $config_opts->{'kickstart_mount_point'}; # Check for both potential Apache groups (SUSE/RHEL) my $www_gid = getgrnam(`grep -hsoP "(?<=Group ).*" /etc/httpd/conf/*.conf /etc/apache2/*.conf | tr -d '\n'`); - chown -1, $www_gid, $config_opts->{'mount_point'} . '/systems'; + chown $www_uid, $www_gid, $config_opts->{'mount_point'} . '/systems'; } @@ -132,16 +107,12 @@ setup_mod_ssl(\%opts, \%answers); print Spacewalk::Setup::loc("* Creating SSL certificates.\n"); setup_ssl_certs(\%opts, \%answers); -if(not $opts{"skip-reportdb-setup"}) { - Spacewalk::Setup::postgresql_reportdb_setup(\%opts, \%answers); - print Spacewalk::Setup::loc("* Report DB Configured. \n"); -} +Spacewalk::Setup::postgresql_reportdb_setup(\%opts, \%answers); +print Spacewalk::Setup::loc("* Report DB Configured. \n"); -if(not $opts{"skip-db-population"}) { - print Spacewalk::Setup::loc("* Update configuration in database.\n"); - final_db_config(\%opts, \%answers); -} +print Spacewalk::Setup::loc("* Update configuration in database.\n"); +final_db_config(\%opts, \%answers); print Spacewalk::Setup::loc("* Setting up Cobbler..\n"); setup_cobbler(\%opts, \%answers); @@ -149,87 +120,10 @@ setup_cobbler(\%opts, \%answers); print Spacewalk::Setup::loc("* Deploying configuration files.\n"); populate_final_configs(\%opts, \%answers); -if ($opts{'upgrade'}) { - Spacewalk::Setup::postgresql_start() if (Spacewalk::Setup::is_embedded_db(\%opts)); - - print Spacewalk::Setup::loc("This portion of the $product_name upgrade process has successfully completed.\n"); - if ($product_name =~ /Satellite/) { - print Spacewalk::Setup::loc("Please refer to appropriate upgrade document in /etc/sysconfig/rhn/satellite-upgrade\n"); - print Spacewalk::Setup::loc("for any remaining steps in the process.\n"); - } -} else { - if (!$opts{'skip-services-restart'}){ - print Spacewalk::Setup::loc("* Restarting services.\n"); - Spacewalk::Setup::system_or_exit(['/usr/sbin/spacewalk-service', 'restart'], 40, - 'Could not restart spacewalk services.'); - wait_for_tomcat() or exit 56; - } - print Spacewalk::Setup::loc("Installation complete.\n"); -} +print Spacewalk::Setup::loc("Installation complete.\n"); exit 0; - -sub remove_old_jvm { - my $opts = shift; - my $answers = shift; - - return unless (($opts{"upgrade"}) and ($product_name =~ /Satellite/)); - - my $jvm_list = Spacewalk::Setup::SHARED_DIR . "/old-jvm-list"; - - local *F; - open F, $jvm_list or die "Error opening [$jvm_list]: $!\n"; - my @jvms = ; - close F; - chomp @jvms; - - my $remove; - - foreach my $jvm (@jvms) { - system("rpm -q $jvm >& /dev/null"); - $remove .= " $jvm" unless $? >> 8; - } - - if ($remove) { - print Spacewalk::Setup::loc("Setup found following old java packages:\n"); - foreach my $p (split (" ", $remove)) { - print Spacewalk::Setup::loc("\t$p\n"); - } - } else { - return; - } - - Spacewalk::Setup::ask( - -noninteractive => $opts{"non-interactive"}, - -question => "Should setup remove these packages", - -test => sub { my $text = shift; return $text =~ /^[YyNn]/ }, - -answer => \$answers->{"remove-old-jvm"}, - -default => 'Y', - ); - unless ( $answers->{"remove-old-jvm"} =~ /^[Yy]/ ) { - print Spacewalk::Setup::loc("** Skipping removal of old java packages.\n"); - return; - } - - my $result = `rpm -e $remove 2>&1`; - if ($? >> 8) { - print Spacewalk::Setup::loc("** Error occurred while removing the packages:\n"); - print Spacewalk::Setup::loc($result); - } -} - -sub remove_tomcat_cache { - my $opts = shift; - - return unless ($opts->{'upgrade'}); - - my @dirs = glob "/var/cache/tomcat?/work"; - if (scalar @dirs > 0) { - system("rm -rf /var/cache/tomcat?/work/* > /dev/null 2>&1"); - } -} - sub setup_cobbler { my $opts = shift; my $answers = shift; @@ -237,8 +131,8 @@ sub setup_cobbler { my %options = (); Spacewalk::Setup::read_config('/usr/share/rhn/config-defaults/rhn.conf',\%options); - Spacewalk::Setup::system_or_exit([COBBLER_COMMAND, '--apache2-config-directory', $options{'httpd_config_dir'}, '-f', $answers->{'hostname'}], 1, - 'Could not setup cobbler'); + system("spacewalk-setup-cobbler --apache2-config-directory $options{'httpd_config_dir'} -f $answers->{'hostname'}") == 0 + or die 'Could not setup cobbler'; my $skip_rhnconf = 0; open(FILE, "<" . Spacewalk::Setup::DEFAULT_RHN_CONF_LOCATION); @@ -261,32 +155,7 @@ sub setup_cobbler { system("cobbler sync"); } - Spacewalk::Setup::ask( - -noninteractive => $opts{"non-interactive"}, - -question => "Cobbler requires tftp and xinetd services be turned on for PXE provisioning functionality. Enable these services", - -test => sub { my $text = shift; return $text =~ /^[YyNn]/ }, - -answer => \$answers->{"enable-tftp"}, - -default => 'Y', - ); - - if ($opts{'enable-tftp'}) { - $answers{'enable-tftp'} = $opts{'enable-tftp'}; - } - - if (($answers{'enable-tftp'} and $answers{'enable-tftp'} =~ /^[Yy]/) || $opts{"non-interactive"}) { - if (-e '/usr/lib/systemd/system/tftp.socket') { - system("systemctl --quiet enable tftp.socket 2>&1"); - system("systemctl start tftp.socket 2>&1"); - } else { - if (-e '/usr/lib/systemd/system/atftpd.socket') { - system("systemctl --quiet enable atftpd.socket 2>&1"); - system("systemctl start atftpd.socket 2>&1"); - } else { - system("systemctl --quiet enable atftpd.service 2>&1"); - system("systemctl start atftpd.service 2>&1"); - } - } - } + system("systemctl enable tftp.socket") } sub setup_admin_email { @@ -298,7 +167,6 @@ sub setup_admin_email { $answers->{'admin-email'} = $rhnoptions->{'traceback_mail'}; } else { Spacewalk::Setup::ask( - -noninteractive => $opts{"non-interactive"}, -question => "Admin Email Address", -test => sub { my $text = shift; valid_multiple_email($text) && length($text) <= 128 }, @@ -362,19 +230,16 @@ sub setup_cc { $opts{disconnected} = 1; $answers{'setup-scc'} = 'Y'; Spacewalk::Setup::ask( - -noninteractive => $opts{"non-interactive"}, -question => "SCC Organization Credential Username", -test => sub { my $text = shift; return $text =~ /\S+/ && length($text) <= 128 }, -answer => \$answers{'scc-user'}); Spacewalk::Setup::ask( - -noninteractive => $opts{"non-interactive"}, -question => "SCC Organization Credential Password", -test => sub { my $text = shift; return $text =~ /\S+/ && length($text) <= 128 }, - -answer => \$answers{'scc-pass'}, - -password => 1); + -answer => \$answers{'scc-pass'}); } @@ -457,7 +322,6 @@ sub setup_mod_ssl { return; } Spacewalk::Setup::ask( - -noninteractive => $opts{"non-interactive"}, -question => "Should setup configure apache's default ssl server for you (saves original ssl.conf)", -test => sub { my $text = shift; return $text =~ /^[YyNn]/ }, -answer => \$answers->{"ssl-config-sslvhost"}, @@ -478,13 +342,12 @@ sub setup_ssl_certs { my $opts = shift; my $answers = shift; - if ($opts{"skip-ssl-cert-generation"} || $opts{"upgrade"}) { + if ($opts{"skip-ssl-cert-generation"}) { print Spacewalk::Setup::loc("** Skipping SSL certificate generation.\n"); return; } Spacewalk::Setup::ask( - -noninteractive => $opts{"non-interactive"}, -question => "Do you want to import exising certificates?", -test => sub { my $text = shift; return $text =~ /^[YyNn]/ }, -answer => \$answers->{"ssl-use-existing-certs"}, @@ -503,30 +366,24 @@ sub setup_ssl_certs { do { ($password_1, $password_2) = (undef, undef); # clear previous passwords Spacewalk::Setup::ask( - -noninteractive => $opts{"non-interactive"}, -question => "CA certificate password", -test => \&valid_ssl_cert_password, -answer => \$password_1, - -password => 1, ); Spacewalk::Setup::ask( - -noninteractive => $opts{"non-interactive"}, -question => "Re-enter CA certificate password", -test => \&valid_ssl_cert_password, -answer => \$password_2, - -password => 1, ); } until (passwords_match($password_1, $password_2)); } else { do { $password_1 = undef; Spacewalk::Setup::ask( - -noninteractive => $opts{"non-interactive"}, -question => "CA certificate password", -test => \&valid_ssl_cert_password, -answer => \$password_1, - -password => 1, ); } until (check_ca_key($password_1)==0); } @@ -534,7 +391,6 @@ sub setup_ssl_certs { }; Spacewalk::Setup::ask( - -noninteractive => $opts{"non-interactive"}, -question => "Cname alias of the machine (comma separated)", -test => sub { my $text = shift; return length($text) <= 128 }, @@ -542,7 +398,6 @@ sub setup_ssl_certs { ); Spacewalk::Setup::ask( - -noninteractive => $opts{"non-interactive"}, -question => "Organization", -test => sub { my $text = shift; return $text =~ /\S/ && length($text) <= 128 }, @@ -550,7 +405,6 @@ sub setup_ssl_certs { ); Spacewalk::Setup::ask( - -noninteractive => $opts{"non-interactive"}, -question => "Organization Unit", -test => sub { my $text = shift; return $text =~ /\S/ && length($text) <= 128 }, @@ -561,7 +415,6 @@ sub setup_ssl_certs { $answers->{"ssl-set-common-name"} ||= $answers->{hostname}; Spacewalk::Setup::ask( - -noninteractive => $opts{"non-interactive"}, -question => 'Email Address', -test => sub { my $text = shift; valid_multiple_email($text) && length($text) <= 128 }, @@ -570,7 +423,6 @@ sub setup_ssl_certs { ); Spacewalk::Setup::ask( - -noninteractive => $opts{"non-interactive"}, -question => 'City', -test => sub { my $text = shift; $text =~ /\S+/ && length($text) < 128 }, @@ -578,7 +430,6 @@ sub setup_ssl_certs { ); Spacewalk::Setup::ask( - -noninteractive => $opts{"non-interactive"}, -question => 'State', -test => sub { my $text = shift; length($text) > 0 && length($text) < 128 }, @@ -591,7 +442,6 @@ sub setup_ssl_certs { or not (exists $by_code->{$answers->{'ssl-set-country'}} or exists $by_name->{$answers->{'ssl-set-country'}})) { Spacewalk::Setup::ask( - -noninteractive => $opts{"non-interactive"}, -question => 'Country code (Examples: "US", "JP", "IN", or type "?" to see a list)', -test => sub { my $text = shift; exists $by_code->{$text} or exists $by_name->{$text} or $text eq '?' }, @@ -612,21 +462,18 @@ sub setup_ssl_certs { $answers->{'ssl-server-cert-expiration'} ||= default_cert_expiration(); } else { Spacewalk::Setup::ask( - -noninteractive => $opts{"non-interactive"}, -question => "Path to CA Certificate", -test => sub { my $text = shift; length($text) > 0 && -r $text && -s $text }, -answer => \$answers->{"ssl-ca-cert"}, ); Spacewalk::Setup::ask( - -noninteractive => $opts{"non-interactive"}, -question => "Path to Server Certificate", -test => sub { my $text = shift; length($text) > 0 && -r $text && -s $text }, -answer => \$answers->{"ssl-server-cert"}, ); Spacewalk::Setup::ask( - -noninteractive => $opts{"non-interactive"}, -question => "Path to Server Key", -test => sub { my $text = shift; length($text) > 0 && -r $text && -s $text }, @@ -787,16 +634,15 @@ sub populate_initial_configs { Spacewalk::Setup::set_hibernate_conf($answers); # Set the document root depending on OS. - my $DOC_ROOT = $Spacewalk::Setup::DEFAULT_DOC_ROOT; - $DOC_ROOT = $Spacewalk::Setup::SUSE_DOC_ROOT if(is_suse_like()); + my $DOC_ROOT = $Spacewalk::Setup::SUSE_DOC_ROOT; my %config_opts = ( mount_point => $answers->{'mount-point'} || '/var/spacewalk', kickstart_mount_point => $answers->{'kickstart-mount-point'} || $answers->{'mount-point'} || '/var/spacewalk', - serverDOTsatelliteDOThttp_proxy => ($opts->{'rhn-http-proxy'} ? $opts->{'rhn-http-proxy'} : $answers->{'rhn-http-proxy'}) || '', - serverDOTsatelliteDOThttp_proxy_username => ($opts->{'rhn-http-proxy'} ? $opts->{'rhn-http-proxy-username'} : $answers->{'rhn-http-proxy-username'}) || '', - serverDOTsatelliteDOThttp_proxy_password => ($opts->{'rhn-http-proxy'} ? $opts->{'rhn-http-proxy-password'} :$answers->{'rhn-http-proxy-password'}) || '', + serverDOTsatelliteDOThttp_proxy => $answers->{'rhn-http-proxy'} || '', + serverDOTsatelliteDOThttp_proxy_username => $answers->{'rhn-http-proxy-username'} || '', + serverDOTsatelliteDOThttp_proxy_password => $answers->{'rhn-http-proxy-password'} || '', javaDOThostname => $answers->{hostname}, encrypted_passwords => 1, db_backend => $answers->{'db-backend'}, @@ -887,13 +733,6 @@ sub populate_initial_configs { return \%config_opts; } -# given a list of directories (by default, /var/satellite) -# check if they exist and if they do not exist, create them -# with apache as owner -sub mkdir_mount_points { - system('/usr/bin/spacewalk-make-mount-points', @_); -} - sub populate_final_configs { my $options = shift; my $answers = shift; @@ -902,7 +741,7 @@ sub populate_final_configs { -dest => '/etc/rhn'); if($answers->{"no-ssl"} && $answers->{"no-ssl"} =~ /^[Yy]/) { open(my $FILE, '>>', '/etc/rhn/rhn.conf'); - print $FILE "server.no_ssl = 1"; + print $FILE "server.no_ssl = 1\n"; close $FILE; } @@ -980,22 +819,6 @@ sub setup_services { return 1; } -sub is_suse_like { - my $filename = '/etc/os-release'; - if(! -e $filename) { - return; - } - open my $fh, "<", $filename or die "Could not open '$filename': $!\n"; - while( my $line = <$fh> ) { - if ($line =~ m/ID_LIKE=".*suse.*"/) { - close $fh; - return 1; - } - } - close $fh; - return; -} - sub check_ca_key{ my $password = shift; return Spacewalk::Setup::system_debug('/usr/bin/rhn-ssl-tool',"--check-key", "--password=$password"); diff --git a/spacewalk/setup/lib/Spacewalk/Setup.pm b/spacewalk/setup/lib/Spacewalk/Setup.pm index 404165d8e166..d86ca45d356e 100644 --- a/spacewalk/setup/lib/Spacewalk/Setup.pm +++ b/spacewalk/setup/lib/Spacewalk/Setup.pm @@ -8,7 +8,7 @@ use English; use Exporter 'import'; use vars '@EXPORT_OK'; -@EXPORT_OK = qw(loc system_debug system_or_exit postgresql_clear_db); +@EXPORT_OK = qw(loc system_debug system_or_exit); use Getopt::Long qw(GetOptions); use Symbol qw(gensym); @@ -49,12 +49,6 @@ use constant SHARED_DIR => "/usr/share/spacewalk/setup"; use constant POSTGRESQL_SCHEMA_FILE => File::Spec->catfile("/usr", "share", 'susemanager', 'db', 'postgres', 'main.sql'); -use constant POSTGRESQL_DEPLOY_FILE => File::Spec->catfile("/usr", "share", - 'susemanager', 'db', 'postgres', 'deploy.sql'); - -use constant DEFAULT_ANSWER_FILE_GLOB => - SHARED_DIR . '/defaults.d/*.conf'; - use constant DEFAULT_RHN_CONF_LOCATION => '/etc/rhn/rhn.conf'; @@ -64,12 +58,6 @@ use constant DEFAULT_PROXY_CONF_LOCATION => use constant DEFAULT_PROXYAUTH_CONF_LOCATION => '/root/.curlrc'; -use constant DEFAULT_UP2DATE_LOCATION => - '/etc/sysconfig/rhn/up2date'; - -use constant DEFAULT_RHN_ETC_DIR => - '/etc/sysconfig/rhn'; - use constant DEFAULT_SATCON_DICT => '/var/lib/rhn/rhn-satellite-prep/satellite-local-rules.conf'; @@ -89,23 +77,12 @@ use constant DB_POP_LOG_FILE => '/var/log/rhn/populate_db.log'; use constant PG_POP_LOG_SIZE => 156503; -use constant ORA_POP_LOG_SIZE => 132243; use constant RHN_LOG_DIR => '/var/log/rhn'; -use constant DB_UPGRADE_LOG_FILE => - '/var/log/rhn/upgrade_db.log'; - -use constant DB_UPGRADE_LOG_SIZE => 22000000; - use constant DB_INSTALL_LOG_SIZE => 11416; -use constant DB_MIGRATION_LOG_FILE => - '/var/log/rhn/rhn_db_migration.log'; - -use constant EMBEDDED_DB_ANSWERS => - '/usr/share/spacewalk/setup/defaults.d/embedded-postgresql.conf'; our $DEFAULT_DOC_ROOT = "/var/www/html"; our $SUSE_DOC_ROOT = "/usr/share/susemanager/www/htdocs"; @@ -130,43 +107,21 @@ sub parse_options { my @valid_opts = ( "help", "skip-initial-configuration", - "skip-system-version-test", - "skip-selinux-test", "skip-fqdn-test", - "skip-python-test", - "skip-updates-install", - "skip-db-install", - "skip-db-diskspace-check", - "skip-db-population", - "skip-reportdb-setup", "skip-ssl-cert-generation", "skip-ssl-ca-generation", "skip-ssl-vhost-setup", "skip-services-check", - "skip-services-restart", - "skip-logfile-init", "clear-db", - "re-register", "answer-file=s", - "non-interactive", - "upgrade", - "run-updater:s", - "run-cobbler", - "enable-tftp:s", - "external-postgresql", - "external-postgresql-over-ssl", "db-only", - "rhn-http-proxy:s", - "rhn-http-proxy-username:s", - "rhn-http-proxy-password:s", - "managed-db", "scc", "disconnected" ); my $usage = loc("usage: %s %s\n", $0, - "[ --help ] [ --answer-file= ] [ --non-interactive ] [ --skip-initial-configuration ] [ --skip-system-version-test ] [ --skip-selinux-test ] [ --skip-fqdn-test ] [ --skip-db-install ] [ --skip-db-diskspace-check ] [ --skip-db-population ] [--skip-reportdb-setup ] [ --skip-ssl-cert-generation ] [--skip-ssl-ca-generation] [--skip-ssl-vhost-setup] [ --skip-services-check ] [ --skip-services-restart ] [ --clear-db ] [ --re-register ] [ --upgrade ] [ --run-updater=] [--run-cobbler] [ --enable-tftp=] [ --external-postgresql [ --external-postgresql-over-ssl ] ] [--scc] [--disconnected]" ); + "[ --help ] [ --answer-file= ] [ --skip-initial-configuration ] [ --skip-fqdn-test ] [ --skip-ssl-cert-generation ] [--skip-ssl-ca-generation] [--skip-ssl-vhost-setup] [ --skip-services-check ] [ --clear-db ] [--scc] [--disconnected]" ); # Terminate if any errors were encountered parsing the command line args: my %opts; @@ -238,9 +193,6 @@ sub load_answer_file { my (@skip) = @{(shift)}; my @files = (); - foreach my $afile (glob(DEFAULT_ANSWER_FILE_GLOB)) { - push @files, $afile if not grep $_ eq $afile, @skip; - } push @files, $options->{'answer-file'} if $options->{'answer-file'}; for my $file (@files) { @@ -271,13 +223,6 @@ sub load_answer_file { return; } -# Check if we're installing with an embedded database. -sub is_embedded_db { - my $opts = shift; - return not (defined($opts->{'external-postgresql'}) - or defined($opts->{'managed-db'})); -} - sub system_debug { my @args = @_; @@ -360,28 +305,6 @@ sub system_or_exit { return 1; } -sub upgrade_stop_services { - my $opts = shift; - if ($opts->{'upgrade'} && not $opts->{'skip-services-check'}) { - print "* Upgrade flag passed. Stopping necessary services.\n"; - if (-e "/usr/sbin/spacewalk-service") { - system_or_exit(['/usr/sbin/spacewalk-service', 'stop'], 16, - 'Could not stop the rhn-satellite service.'); - } else { - # shutdown pre 3.6 services proerly - system_or_exit(['/sbin/service', 'apache2', 'stop'], 25, - 'Could not stop the http service.'); - system_or_exit(['/sbin/service', 'taskomatic', 'stop'], 27, - 'Could not stop the taskomatic service.'); - if (is_embedded_db($opts)) { - system_or_exit(['/sbin/service', 'rhn-database', 'stop'], 31, - 'Could not stop the rhn-database service.'); - } - } - } - return 1; -} - my $spinning_callback_count; my @spinning_pattern = split /\n/, <', INSTALL_LOG_FILE and close X; - system('/sbin/restorecon', INSTALL_LOG_FILE); - } log_rotate(DB_INSTALL_LOG_FILE); log_rotate(DB_POP_LOG_FILE); @@ -550,66 +469,23 @@ EOQ # as other routines on account of usage of $opts: sub ask { my %params = validate(@_, { - noninteractive => 1, question => 1, test => 0, answer => 1, - password => 0, default => 0, - completion => 0, }); if (${$params{answer}} and not $params{default}) { $params{default} = ${$params{answer}}; } - while (not defined ${$params{answer}} or - not answered($params{test}, ${$params{answer}})) { - if ($params{noninteractive}) { - if (defined ${$params{answer}}) { - die "The answer '" . ${$params{answer}} . "' provided for '" . $params{question} . "' is invalid.\n"; - } - else { - die "No answer provided for '" . $params{question} . "'\n"; - } - } - - my $default_string = ""; - if ($params{default}) { - if ($params{password}) { - $default_string = " [******]"; - } - else { - $default_string = " [" . $params{default} . "]"; - } - } - - print loc("%s%s? ", - $params{question}, - $default_string); - - if ($params{password}) { - my $stty_orig_val = `stty -g`; - system('stty', '-echo'); - ${$params{answer}} = ; - system("stty $stty_orig_val"); - print "\n"; + if (not defined ${$params{answer}} or not answered($params{test}, ${$params{answer}})) { + if (defined ${$params{answer}}) { + die "The answer '" . ${$params{answer}} . "' provided for '" . $params{question} . "' is invalid.\n"; } else { - if ($params{completion}) { - require Term::Completion::Path; - my $tc = Term::Completion::Path->new(); - ${$params{answer}} = $tc->complete(); - } - else { - ${$params{answer}} = ; - } + die "No answer provided for '" . $params{question} . "'\n"; } - - chomp ${$params{answer}}; - ${$params{answer}} =~ s/^\s+|\s+$//g; - - ${$params{answer}} ||= $params{default} || ''; } ${$params{answer}} ||= $params{default} || ''; @@ -663,56 +539,6 @@ EOQ return %nls_database_parameters; } - -sub print_progress { - my %params = validate(@_, { init_message => 1, - log_file_name => 1, - log_file_size => 1, - err_message => 1, - err_code => 1, - system_opts => 1, - }); - print "Running " . join(" ", @{$params{system_opts}}) . "\n"; - - local *LOGFILE; - open(LOGFILE, ">>", $params{log_file_name}) or do { - print "Error writing log file '$params{log_file_name}': $!\n"; - print STDERR "Error writing log file '$params{log_file_name}': $!\n"; - exit $params{err_code}; - }; - - $| = 1; - my $orig_stdout = select LOGFILE; - $| = 1; - select $orig_stdout; - print loc($params{init_message}); - local *PROCESS_OUT; - my $progress_hashes_done = 0; - my $progress_callback_length = 0; - my $pid = open3(gensym, \*PROCESS_OUT, \*PROCESS_OUT, @{$params{system_opts}}); - while () { - print LOGFILE $_; - $progress_callback_length += length; - if (-t STDOUT and $params{log_file_size}) { - my $target_hashes = int(60 * $progress_callback_length / $params{log_file_size}); - if ($target_hashes > $progress_hashes_done) { - print "#" x ($target_hashes - $progress_hashes_done); - $progress_hashes_done = $target_hashes; - } - } - } - close PROCESS_OUT; - waitpid($pid, 0); - my $ret = $?; - close LOGFILE; - print "\n"; - - if ($ret) { - print loc($params{err_message}); - exit $params{err_code}; - } -} - sub postgresql_get_database_answers { my $opts = shift; my $answers = shift; @@ -721,7 +547,6 @@ sub postgresql_get_database_answers { read_config(DEFAULT_RHN_CONF_LOCATION, \%config); ask( - -noninteractive => $opts->{"non-interactive"}, -question => "Hostname (leave empty for local)", -test => sub { 1 }, -answer => \$answers->{'db-host'}); @@ -729,7 +554,6 @@ sub postgresql_get_database_answers { if ($answers->{'db-host'} ne '') { $answers->{'db-host'} = idn_to_ascii($answers->{'db-host'}, "utf8"); ask( - -noninteractive => $opts->{"non-interactive"}, -question => "Port", -test => qr/\d+/, -default => 5432, @@ -739,36 +563,22 @@ sub postgresql_get_database_answers { } ask( - -noninteractive => $opts->{"non-interactive"}, -question => "Database", -test => qr/\S+/, -default => $config{'db_name'}, -answer => \$answers->{'db-name'}); ask( - -noninteractive => $opts->{"non-interactive"}, -question => "Username", -test => qr/\S+/, -default => $config{'db_user'}, -answer => \$answers->{'db-user'}); ask( - -noninteractive => $opts->{"non-interactive"}, -question => "Password", -test => qr/\S+/, -default => $config{'db_password'}, - -answer => \$answers->{'db-password'}, - -password => 1); - - if ($opts->{'external-postgresql-over-ssl'}) { - $answers->{'db-ssl-enabled'} = '1'; - ask( - -noninteractive => $opts->{"non-interactive"}, - -question => "Path to CA certificate for connection to database", - -test => sub { return (-f shift) }, - -default => $ENV{HOME} . "/.postgresql/root.crt", - -answer => \$answers->{'db-ca-cert'}); - } + -answer => \$answers->{'db-password'}); return; } @@ -781,7 +591,6 @@ sub postgresql_get_reportdb_answers { read_config(DEFAULT_RHN_CONF_LOCATION, \%config); ask( - -noninteractive => $opts->{"non-interactive"}, -question => "Hostname (leave empty for local)", -test => sub { 1 }, -answer => \$answers->{'report-db-host'}); @@ -789,7 +598,6 @@ sub postgresql_get_reportdb_answers { if ($answers->{'report-db-host'} ne '') { $answers->{'report-db-host'} = idn_to_ascii($answers->{'report-db-host'}, "utf8"); ask( - -noninteractive => $opts->{"non-interactive"}, -question => "Port", -test => qr/\d+/, -default => 5432, @@ -799,28 +607,23 @@ sub postgresql_get_reportdb_answers { } ask( - -noninteractive => $opts->{"non-interactive"}, -question => "Database", -test => qr/\S+/, -default => $config{'report_db_name'}, -answer => \$answers->{'report-db-name'}); ask( - -noninteractive => $opts->{"non-interactive"}, -question => "Username", -test => qr/\S+/, -default => $config{'report_db_user'}, -answer => \$answers->{'report-db-user'}); ask( - -noninteractive => $opts->{"non-interactive"}, -question => "Password (leave empty for autogenerated password)", -test => sub { 1 }, - -answer => \$answers->{'report-db-password'}, - -password => 1); + -answer => \$answers->{'report-db-password'}); ask( - -noninteractive => $opts->{"non-interactive"}, -question => "Path to CA certificate to connect to the reporting database", -test => sub { return (-f shift) }, -default => "/etc/pki/trust/anchors/LOCAL-RHN-ORG-TRUSTED-SSL-CERT", @@ -841,19 +644,9 @@ sub postgresql_setup_db { print Spacewalk::Setup::loc("** Database: Setting up database connection for PostgreSQL backend.\n"); my $connected; - if (is_embedded_db($opts)) { - postgresql_start(); - } - postgresql_setup_embedded_db($opts, $answers); - while (not $connected) { postgresql_get_database_answers($opts, $answers); - if ($opts->{'external-postgresql-over-ssl'}) { - $ENV{PGSSLROOTCERT} = $answers->{'db-ca-cert'}; - $ENV{PGSSLMODE} = "verify-full"; - } - my $dbh; eval { @@ -923,13 +716,8 @@ sub postgresql_reportdb_setup { push @cmd, "--autogenpw"; } - print_progress(-init_message => "*** Progress: #", - -log_file_name => DB_INSTALL_LOG_FILE, - -log_file_size => DB_INSTALL_LOG_SIZE, - -err_message => "Could not install report database.\n", - -err_code => 15, - -system_opts => \@cmd); - + system(@cmd) == 0 or die "Could not install report database"; + if (-e Spacewalk::Setup::DEFAULT_RHN_CONF_LOCATION) { my %dbOptions = (); ### uyuni-setup-reportdb writes param in rhn.conf. We need to read them and persists them in satellite-local-rules.conf @@ -949,77 +737,6 @@ sub postgresql_start { return ($? >> 8); } -sub postgresql_setup_embedded_db { - my $opts = shift; - my $answers = shift; - - if (not is_embedded_db($opts)) { - return 0; - } - - if ($opts->{"skip-db-install"} or $opts->{"upgrade"}) { - print loc("** Database: Embedded database installation SKIPPED.\n"); - return 0; - } - - if (not -x '/usr/bin/spacewalk-setup-postgresql') { - print loc(<{'db-name'}})) { - my $shared_dir = SHARED_DIR; - print loc(<{'db-name'} --user $answers->{'db-user'}' -script to remove the embedded database and try again. -EOQ - - exit 13; - } - - if (not $opts->{"skip-db-diskspace-check"}) { - system_or_exit(['python3', SHARED_DIR . - '/embedded_diskspace_check.py', '$pgdata', '12288'], 14, - 'There is not enough space available for the embedded database.'); - } - else { - print loc("** Database: Embedded database diskspace check SKIPPED!\n"); - } - - printf loc(<', DB_INSTALL_LOG_FILE and close X; - system('/sbin/restorecon', DB_INSTALL_LOG_FILE); - } - print_progress(-init_message => "*** Progress: #", - -log_file_name => DB_INSTALL_LOG_FILE, - -log_file_size => DB_INSTALL_LOG_SIZE, - -err_message => "Could not install database.\n", - -err_code => 15, - -system_opts => [ "/usr/bin/spacewalk-setup-postgresql", - "create", - "--db", $answers->{'db-name'}, - "--user", $answers->{'db-user'}, - "--password", $answers->{'db-password'}]); - - print loc("** Database: Installation complete.\n"); - - return 1; -} - sub postgresql_populate_db { my $opts = shift; my $answers = shift; @@ -1027,11 +744,6 @@ sub postgresql_populate_db { print Spacewalk::Setup::loc("** Database: Populating database.\n"); - if ($opts->{"skip-db-population"} or ($opts->{'upgrade'} and not $populate_db)) { - print Spacewalk::Setup::loc("** Database: Skipping database population.\n"); - return 1; - } - if ($opts->{"clear-db"}) { print Spacewalk::Setup::loc("** Database: --clear-db option used. Clearing database.\n"); my $dbh = get_dbh($answers); @@ -1039,47 +751,19 @@ sub postgresql_populate_db { } if (postgresql_test_db_schema($answers)) { - ask( - -noninteractive => $opts->{"non-interactive"}, - -question => "The Database has schema. Would you like to clear the database", - -test => qr/(Y|N)/i, - -answer => \$answers->{'clear-db'}, - -default => 'Y', - ); - - if ($answers->{"clear-db"} =~ /Y/i) { - print Spacewalk::Setup::loc("** Database: Clearing database.\n"); - my $dbh = get_dbh($answers); - postgresql_clear_db($dbh, $answers); - print Spacewalk::Setup::loc("** Database: Re-populating database.\n"); - } - else { - print Spacewalk::Setup::loc("** Database: The database already has schema. Skipping database population.\n"); - return 1; - } + print Spacewalk::Setup::loc("** Database: Clearing database.\n"); + my $dbh = get_dbh($answers); + postgresql_clear_db($dbh, $answers); + print Spacewalk::Setup::loc("** Database: Re-populating database.\n"); } my $sat_schema = POSTGRESQL_SCHEMA_FILE; - my $sat_schema_deploy = POSTGRESQL_DEPLOY_FILE; - - system_or_exit([ "/usr/bin/rhn-config-schema.pl", - "--source=" . $sat_schema, - "--target=" . $sat_schema_deploy, - "--tablespace-name=None" ], - 22, - 'There was a problem populating the deploy.sql file.', - ); my $logfile = DB_POP_LOG_FILE; - my @opts = ('spacewalk-sql', '--select-mode-direct', $sat_schema_deploy); + my @opts = ('spacewalk-sql', '--select-mode-direct', $sat_schema); - print_progress(-init_message => "*** Progress: #", - -log_file_name => Spacewalk::Setup::DB_POP_LOG_FILE, - -log_file_size => Spacewalk::Setup::PG_POP_LOG_SIZE, - -err_message => "Could not populate database.\n", - -err_code => 23, - -system_opts => [@opts]); + system(@opts) == 0 or die "Could not populate database."; return 1; } @@ -1121,15 +805,6 @@ my @POSTGRESQL_CLEAR_SCHEMA = ( sub postgresql_clear_db { my $dbh = shift; my $answers = shift; - my $do_shutdown = (defined($_[0]) ? shift : 1); - - if ($do_shutdown) { - print loc("** Database: Shutting down spacewalk services that may be using DB.\n"); - - # The --exclude=postgresql is needed for embedded database Satellites. - system_debug('/usr/sbin/spacewalk-service', '--exclude=postgresql', 'stop'); - print loc("** Database: Services stopped. Clearing DB.\n"); - } local $dbh->{RaiseError} = 0; local $dbh->{PrintError} = 1; @@ -1170,43 +845,22 @@ sub get_dbh { AutoCommit => 0, }; - my $backend = $reportdb ? $answers->{'report-db-backend'} : $answers->{'db-backend'}; - - if ($backend eq 'postgresql') { - my $dsn = "dbi:Pg:dbname="; - $dsn .= $reportdb ? $answers->{'report-db-name'} : $answers->{'db-name'}; - my $dbhost = $reportdb ? $answers->{'report-db-host'} : $answers->{'db-host'}; - my $dbport = $reportdb ? $answers->{'report-db-port'} : $answers->{'db-port'}; - if ($dbhost ne '' && $dbhost ne 'localhost') { - $dsn .= ";host=$dbhost"; - if ($dbport ne '') { - $dsn .= ";port=$dbport"; - } + my $dsn = "dbi:Pg:dbname="; + $dsn .= $reportdb ? $answers->{'report-db-name'} : $answers->{'db-name'}; + my $dbhost = $reportdb ? $answers->{'report-db-host'} : $answers->{'db-host'}; + my $dbport = $reportdb ? $answers->{'report-db-port'} : $answers->{'db-port'}; + if ($dbhost ne '' && $dbhost ne 'localhost') { + $dsn .= ";host=$dbhost"; + if ($dbport ne '') { + $dsn .= ";port=$dbport"; } - my $dbh = DBI->connect($dsn, - $reportdb ? $answers->{'report-db-user'} : $answers->{'db-user'}, - $reportdb ? $answers->{'report-db-password'} : $answers->{'db-password'}, - $dbh_attributes); - - return $dbh; } + my $dbh = DBI->connect($dsn, + $reportdb ? $answers->{'report-db-user'} : $answers->{'db-user'}, + $reportdb ? $answers->{'report-db-password'} : $answers->{'db-password'}, + $dbh_attributes); - die "Unknown db-backend [$backend]\n"; -} - -# Function to check that we have SELinux, in the sense that we are on -# system with modular SELinux (> RHEL 4), and the module spacewalk is loaded. -my $have_selinux; -sub have_selinux { - return $have_selinux if defined $have_selinux; - if( not -x "/usr/sbin/selinuxenabled") { - $have_selinux = 0; - } elsif (system(q!/usr/sbin/selinuxenabled && /usr/sbin/semodule -l 2> /dev/null | grep '^spacewalk\b' 2>&1 > /dev/null!)) { - $have_selinux = 0; - } else { - $have_selinux = 1; - } - return $have_selinux; + return $dbh; } sub generate_satcon_dict { @@ -1304,32 +958,13 @@ Indicates the location of an answer file to be use for answering questions asked during the installation process. See answers.txt for an example. -=item B<--non-interactive> - -For use only with --answer-file. If the --answer-file doesn't provide -a required response, exit instead of prompting the user. - # todo @ -=item B<--re-register> - -Register the system with RHN, even if it is already registered. =item B<--clear-db> Clear any pre-existing database schema before installing. This will destroy any data in the Satellite database and re-create -empty Satellite schema. This option implies B<--skip-db-install>. - -=item B<--skip-system-version-test> - -Do not test the Red Hat Enterprise Linux version before installing. - -=item B<--skip-selinux-test> - -For the installation and setup to proceed properly, SELinux should -be in Permissive or Enforcing mode. If you are certain that -you are not in Disabled mode or you want to install in -Disabled anyway, re-run the installer with the flag --skip-selinux-test. +empty Satellite schema. =item B<--skip-fqdn-test> @@ -1338,20 +973,6 @@ requires that the hostname be properly set during installation. Using this option may result in a Satellite server that is not fully functional. -=item B<--skip-db-install> - -Do not install the embedded database. This option may be useful if you -are re-installing the satellite, and do not want to clear the database. - -=item B<--skip-db-diskspace-check> - -Do not check to make sure there is enough free disk space to install -the embedded database. - -=item B<--skip-db-population> - -Do not populate the database schema. - =item B<--skip-ssl-cert-generation> Do not generate the SSL certificates for the Satellite. @@ -1372,43 +993,10 @@ RewriteEngine on RewriteOptions inherit SSLProxyEngine on -=item B<--upgrade> - -Only runs necessary steps for a Satellite upgrade. - =item B<--skip-services-check> Proceed with upgrade if services are already stopped. -=item B<--skip-services-restart> - -Do not restart services at the end of installation. - -=item B<--run-updater=> - -Set to 'yes' to automatically install needed packages from RHSM, provided the system is registered. Set to 'no' to terminate the installer if any needed packages are missing. - -=item B<--run-cobbler> - -Only runs the necessary steps to setup cobbler - -=item B<--enable-tftp=> - -Set to 'yes' to automatically enable tftp and xinetd services needed for Cobbler PXE provisioning functionality. Set to 'no' if you do not want the installer to enable these services. - -=item B<--external-postgresql> - -Assume the Red Hat Satellite installation uses an external PostgreSQL database (Red Hat Satellite only). - -=item B<--external-postgresql-over-ssl> - -When used, installation will assume that external PostgreSQL server allows only connections over SSL. -This option is supposed to be used only in conjuction with B<--external-postgresql>. - -=item B<--managed-db> - -Setup PostgreSQL database for multi-server installation (database and Spacewalk / Red Hat Satellite on different machines). - =back =head1 SEE ALSO diff --git a/spacewalk/setup/share/defaults.d/defaults.conf b/spacewalk/setup/share/defaults.d/defaults.conf deleted file mode 100644 index d91405f876ef..000000000000 --- a/spacewalk/setup/share/defaults.d/defaults.conf +++ /dev/null @@ -1,141 +0,0 @@ -# Administrator's email address. Required. -# Multiple email addresses can be used, seperated with commas. -# -# Example: -# admin-email = user@example.com, otheruser@example.com - -admin-email = - - -## RHN connection information. -# -# Passed to rhn-register to register the system if it is not already -# registered. -# -# Only required if the system is not already registered, or if the -# '--re-register' commandline option is used. Not used at all if the -# '--disconnected' commandline option is used. - -#rhn-username = -#rhn-password = - -# HTTP proxy. Not Required. -# -# Example: -# rhn-http-proxy = proxy.example.com:8080 - -#rhn-http-proxy = -#rhn-http-proxy-username = -#rhn-http-proxy-password = - -# RHN Profile name. Not required. Defaults to the system's hostname -# or whatever 'hostname' is set to. - -# rhn-profile-name = - - -## SSL certificate information. - -# The name of your organization. Required. -# -# Example: -# ssl-set-org = Riboflavin, Inc. - -ssl-set-org = - -# The unit within the organization that the satellite is assigned to. -# Not required. -# -# Example: -# ssl-set-org-unit = Information Systems Department - -ssl-set-org-unit = - -# Location information for the SSL certificates. Required. -# -# Example: -# ssl-set-city = New York -# ssl-set-state = NY -# ssl-set-country = US - -ssl-set-city = -ssl-set-state = -ssl-set-country = - -# Password for CA certificate. Required. Do not lose or forget this -# password! -# -# Example: -# ssl-password = c5esWL7s - -ssl-password = - - -## Database connection information. -# -# Required if the database is an external (not embedded) database. - -# db-user = -# db-password = -# db-host = -# db-name = -# db-port = 1521 - -## Apache conf.d/ssl.conf virtual host definition reconfiguration -# -# A value of "Y" or "y" here will cause the installer to make a numbered -# backup of the system's existing httpd/conf.d/ssl.conf file and replace -# the original with one that's set up properly to work with Spacewalk. -# The recommended answer is Y -# -# ssl-config-sslvhost = - - -# *** Options below this line usually don't need to be set. *** - -# The Satellite server's hostname. This must be the working FQDN of -# the satellite server. -# -# hostname = - -# The mount point for the RHN package repository. Defaults to -# /var/rhn/satellite -# -# mount-point = - -# Mail configuration. -# -# mail-mx = -# mdom = - -# 'Common name' for the SSL certificates. Defaults to the system's -# hostname, or whatever 'hostname' is set to. -# -# ssl-set-common-name = - -# The email address for the SSL certificates. Defaults to 'admin-email'. -# -# ssl-set-email = - -# The expiration (in years) for the satellite certificates. Defaults -# to the number of years until 2037. -# -# ssl-ca-cert-expiration = -# ssl-server-cert-expiration = - - - - -# *** For troubleshooting/testing only. *** -# - -rhn-parent = satellite.rhn.redhat.com - -# ssl-dir = -# ssl-server-rpm = - -# If this machine is registered to RHN, install RHEL packages that are -# needed for Satellite on top of @base group. -# The default is to ask. -# -# run-updater = diff --git a/spacewalk/setup/spacewalk-setup.changes.cbosdo.systemd-free-setup b/spacewalk/setup/spacewalk-setup.changes.cbosdo.systemd-free-setup new file mode 100644 index 000000000000..5969585d407d --- /dev/null +++ b/spacewalk/setup/spacewalk-setup.changes.cbosdo.systemd-free-setup @@ -0,0 +1 @@ +- Clean up unused code diff --git a/spacewalk/setup/spacewalk-setup.spec b/spacewalk/setup/spacewalk-setup.spec index d7b36b2ae2df..4dac190e85fc 100644 --- a/spacewalk/setup/spacewalk-setup.spec +++ b/spacewalk/setup/spacewalk-setup.spec @@ -168,8 +168,6 @@ install -m 0644 share/server_update.xml.xsl %{buildroot}%{_datadir}/spacewalk/se install -m 0644 share/add_appbase.xml.xsl %{buildroot}%{_datadir}/spacewalk/setup/ install -m 0644 share/old-jvm-list %{buildroot}%{_datadir}/spacewalk/setup/ install -m 0644 share/vhost-nossl.conf %{buildroot}%{_datadir}/spacewalk/setup/ -install -d -m 755 %{buildroot}%{_datadir}/spacewalk/setup/defaults.d/ -install -m 0644 share/defaults.d/defaults.conf %{buildroot}%{_datadir}/spacewalk/setup/defaults.d/ install -d -m 755 %{buildroot}%{_datadir}/spacewalk/setup/cobbler install -m 0644 salt/susemanager.conf %{buildroot}%{_sysconfdir}/salt/master.d/ install -m 0644 salt/salt-ssh-logging.conf %{buildroot}%{_sysconfdir}/salt/master.d/ @@ -178,7 +176,6 @@ install -m 0644 salt/salt-ssh-logging.conf %{buildroot}%{_sysconfdir}/salt/maste install -d -m 755 %{buildroot}/%{misc_path}/spacewalk mkdir -p %{buildroot}%{_mandir}/man8 -%{_bindir}/pod2man --section=8 %{buildroot}%{_bindir}/spacewalk-make-mount-points | gzip > %{buildroot}%{_mandir}/man8/spacewalk-make-mount-points.8.gz %{_bindir}/pod2man --section=1 %{buildroot}%{_bindir}/spacewalk-setup-httpd | gzip > %{buildroot}%{_mandir}/man1/spacewalk-setup-httpd.1.gz # Sphinx built manpage %define SPHINX_BASE_DIR %(echo %{SOURCE0}| sed -e 's/\.tar\.gz//' | sed 's@.*/@@') @@ -233,7 +230,6 @@ exit 0 %{perl_vendorlib}/* %{_bindir}/spacewalk-setup %{_bindir}/spacewalk-setup-httpd -%{_bindir}/spacewalk-make-mount-points %{_bindir}/spacewalk-setup-cobbler %{_mandir}/man[13]/*.[13]* %dir %attr(0755, root, root) %{_datadir}/salt-formulas/ @@ -242,7 +238,6 @@ exit 0 %dir %{_datadir}/spacewalk %{_datadir}/spacewalk/* %attr(755, %{apache_user}, root) %{misc_path}/spacewalk -%{_mandir}/man8/spacewalk-make-mount-points* %license LICENSE %changelog diff --git a/spacewalk/spacewalk-setup-postgresql/LICENSE b/spacewalk/spacewalk-setup-postgresql/LICENSE deleted file mode 100644 index d159169d1050..000000000000 --- a/spacewalk/spacewalk-setup-postgresql/LICENSE +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. diff --git a/spacewalk/spacewalk-setup-postgresql/bin/spacewalk-setup-postgresql b/spacewalk/spacewalk-setup-postgresql/bin/spacewalk-setup-postgresql deleted file mode 100755 index 429beb698c74..000000000000 --- a/spacewalk/spacewalk-setup-postgresql/bin/spacewalk-setup-postgresql +++ /dev/null @@ -1,425 +0,0 @@ -#!/bin/bash - -set -e - -help() { - echo "Usage: $(basename $0) create [options]" >&2 - echo " $(basename $0) remove [options]" >&2 - echo " $(basename $0) check [options]" >&2 - echo "" - echo "Options for the 'create' command:" - echo " --db Name of the database to create" - echo " --user Database user to create" - echo " --password Password for the database user" - echo " --standalone Configure the database server to be remotely accessible" - echo " --address Comma-separated list of local addresses to listen on" - echo " Use '*' for all addresses" - echo " --remote Comma-separated list of remote addresses to allow connections from" - echo " Use address/netmask format" - echo "" - echo "Options for the 'remove' command:" - echo " --db Name of the database to remove" - echo " --user Name of the user to remove" - echo "" - echo "Options for the 'check' command:" - echo " --db Name of the database to check for" - echo " --user Name of the user to check for" -} - -ask() { - if $1; then - read -e -p "$2" $3 - else - read -e -s -p "$2" $3 && echo - fi -} - -isSUSE() { - if [ ! -e '/etc/os-release' ]; then - return 1 - fi - source /etc/os-release - if echo $CPE_NAME | grep -E 'cpe:/o:(open)*suse:' >/dev/null ; then - return 0 - fi - return 1 -} - -ask_check() { - while true; do - ask "$1" "$2" $3 || echo - [[ "${!3}" =~ $4 ]] && break - done -} - -def_regexes() { - local digit seqence n - local IPv4_addr IPv4_mask IPv6_addr IPv6_mask - digit='([0-9]|[1-9][0-9]|1[0-9][0-9]|2([0-4][0-9]|5[0-5]))' - IPv4_addr="($digit\\.){3}$digit" - IPv4_mask='([0-9]|[12][0-9]|3[012])' - - seqence='[[:digit:]abcdefABCDEF]{1,4}' - IPv6_addr="$seqence(:$seqence){7}|::" - - # shortened - IPv6_addr+="|:(:$seqence){1,7}" - for n in 1 2 3 4 5 6; do - IPv6_addr+="|($seqence:){$n}(:|(:$seqence){1,$((7-n))})" - done - IPv6_addr+="|($seqence:){7}:" - - # with IPv4 mixed - - IPv6_addr+="|($seqence:){6}$IPv4_addr|::$IPv4_addr" - for n in 1 2 3 4 5; do - IPv6_addr+="|($seqence:){$n}(:$seqence){0,$((5-n))}:$IPv4_addr" - done - - # final wrap - IPv6_addr="($IPv6_addr)" - IPv6_mask="([0-9]|[1-9][0-9]|1[01][0-9]|12[0-8])" - - local addr="[[:space:]]*($IPv4_addr|$IPv6_addr)[[:space:]]*" - Local_RE="([[:space:]]*|($addr,)*$addr)" - local masked="[[:space:]]*($IPv4_addr/$IPv4_mask|$IPv6_addr/$IPv6_mask)[[:space:]]*" - Remote_RE="(($masked,)*$masked)" -} -def_regexes -unset -f def_regexes - -PG_DATA=/var/lib/pgsql/data -PG_HBA="$PG_DATA/pg_hba.conf" -PG_IDENT="$PG_DATA/pg_ident.conf" -POSTGRESQL="$PG_DATA/postgresql.conf" -POSTGRESQL_SW_APPEND=/usr/share/spacewalk/setup/postgresql.conf -PORT=5432 -PG_PIDFILE="/run/postmaster.$PORT.pid" -if isSUSE ; then - PG_PIDFILE="$PG_DATA/postmaster.pid" -fi -PG_SOCKET="/tmp/.s.PGSQL.$PORT" -SPACEWALK_TARGET="/usr/lib/systemd/system/spacewalk.target" -SERVICE_LIST="/etc/rhn/service-list" -RHN_CONF="/etc/rhn/rhn.conf" - -LSOF="/usr/sbin/lsof" -if [ -x /usr/bin/lsof ]; then - LSOF="/usr/bin/lsof" -fi -RUNUSER=runuser -if isSUSE ; then - RUNUSER=/usr/bin/su -fi - -create() { - [ -z "$PGNAME" ] && ask true "Database name: " PGNAME - [ -z "$PGUSER" ] && ask true "Database user: " PGUSER - [ -z "$PGPASSWORD" ] && ask false "Database password: " PGPASSWORD - - if $STANDALONE; then - [ -z "$ADDRESS" ] && ask_check true "Local addresses to listen on (comma-separated, RETURN for all): " ADDRESS "^$Local_RE\$" - [ -z "$ADDRESS" ] && ADDRESS="*" - [ -z "$REMOTE" ] && ask_check true "Remote addresses to allow connection from (address/netmask format, comma-separated): " REMOTE "^$Remote_RE\$" - fi - - postgresql_service enable - - if [ ! -d "$PG_DATA/base" ] ; then - PGHOME=$(getent passwd postgres | awk -F: '{print $6}') - if /usr/sbin/selinuxenabled; then - SEMODE=$(/usr/sbin/getenforce) - if [ "$SEMODE" = 'Permissive' -o "$SEMODE" = 'Enforcing' ]; then - RCONOUT=$(/sbin/restorecon -Rnv $PGHOME) - if [ -n "$RCONOUT" ]; then - echo - echo "The directory \"$PGHOME\" does not seem to have correct SELinux context." - echo - echo "Please fix the SELinux context by running:" - echo - echo " restorecon -Rv $PGHOME" - echo - exit 1 - fi - fi - fi - echo -e 'LC_CTYPE=en_US.UTF-8\nexport LC_CTYPE' >$PGHOME/.i18n - postgresql_service initdb - fi - - if $STANDALONE; then - sed -i 's/^\(\s*listen_addresses.*\)$/### next line has been commented out by spacewalk-setup-postgresql ###\n##\1/' $POSTGRESQL - fi - - # see bug 821446, we enable timestamps in logs by default - sed -i 's/^\(\s*max_connections.*\|\s*shared_buffers.*\)$/### next line has been commented out by spacewalk-setup-postgresql ###\n##\1/' $POSTGRESQL - cat $POSTGRESQL_SW_APPEND >> $POSTGRESQL - - if $STANDALONE; then - echo "$ADDRESS"|grep -q '127.0.0.1\|*' || ADDRESS="$ADDRESS, 127.0.0.1" - cat >> $POSTGRESQL <> /etc/sysctl.conf ; fi ) - - cat >> $PG_IDENT <> $PG_HBA <> $PG_HBA < $RHN_CONF <& /dev/null && postgresql_service stop - postgresql_service start - - if $LSOF /proc > /dev/null ; then - while [ -f "$PG_PIDFILE" ] ; do - # wait for postmaster to be ready - $LSOF -t -p $(cat "$PG_PIDFILE" 2>/dev/null) -a "$PG_SOCKET" > /dev/null \ - && break - sleep 1 - done - fi - - if ! exists_db ; then - $RUNUSER - postgres -c "createdb -E UTF8 '$PGNAME'" - fi - if ! exists_plpgsql ; then - if is_postgres10 ; then - EXTENSION=$($RUNUSER - postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS plpgsql;" -d '$PGNAME'') - else - $RUNUSER - postgres -c "createlang plpgsql '$PGNAME'" - fi - fi - if ! exists_pltclu ; then - if is_postgres10 ; then - EXTENSION=$($RUNUSER - postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS pltclu;" -d '$PGNAME'') - else - $RUNUSER - postgres -c "createlang pltclu '$PGNAME'" - fi - fi - if ! exists_user ; then - $RUNUSER - postgres -c "yes '$PGPASSWORD' | createuser -P -sDR '$PGUSER'" 2>/dev/null - fi - - postgresql_service reload - - if [ -e "$SPACEWALK_TARGET" ] ; then - if ! grep -q 'Requires=postgresql.service' "$SPACEWALK_TARGET" ; then - sed -i 's/\(Description=Spacewalk\)/\1\nRequires=postgresql.service/' "$SPACEWALK_TARGET" - fi - elif [ -e "$SERVICE_LIST" ]; then - if ! grep -q 'SERVICES=.*postgresql' "$SERVICE_LIST" ; then - echo '' >>"$SERVICE_LIST" - echo '# added by spacewalk-setup-postgresql' >>"$SERVICE_LIST" - echo 'SERVICES="postgresql $SERVICES"' >>"$SERVICE_LIST" - fi - fi -} - -remove() { - if [ -z "$PGUSER" -a -z "$PGNAME" ] ; then - help - exit 1 - fi - if exists_db ; then - $RUNUSER - postgres -c "dropdb '$PGNAME'" - fi - if exists_user ; then - $RUNUSER - postgres -c "dropuser '$PGUSER'" - fi -} - -check() { - if [ -z "$PGUSER" -a -z "$PGNAME" ] ; then - help - exit 1 - fi - - postgresql_service status >& /dev/null || postgresql_service start - - RET=0 - if [ -n "$PGUSER" ] ; then - if exists_user ; then - echo "User \"$PGUSER\" already exists" - else - echo "User \"$PGUSER\" does not exist" - RET=1 - fi - fi - if [ -n "$PGNAME" ] ; then - if exists_db ; then - echo "Database \"$PGNAME\" already exists" - else - echo "Database \"$PGNAME\" does not exist" - RET=1 - fi - fi - exit $RET -} - -is_postgres10() { - NUM=$($RUNUSER - postgres -c 'psql -t -c "SHOW server_version_num;"') - if (( $NUM > 100000 )) ; then - return 0 - else - return 1 - fi -} - -exists_db() { - EXISTS=$($RUNUSER - postgres -c 'psql -t -c "select datname from pg_database where datname='"'$PGNAME'"';"') - if [ "x$EXISTS" == "x $PGNAME" ] ; then - return 0 - else - return 1 - fi -} - -exists_plpgsql() { - EXISTS=$($RUNUSER - postgres -c 'psql -At -c "select lanname from pg_catalog.pg_language where lanname='"'plpgsql'"';"'" $PGNAME") - if [ "x$EXISTS" == "xplpgsql" ] ; then - return 0 - else - return 1 - fi -} - -exists_pltclu() { - EXISTS=$($RUNUSER - postgres -c 'psql -At -c "select lanname from pg_catalog.pg_language where lanname='"'pltclu'"';"'" $PGNAME") - if [ "x$EXISTS" == "xpltclu" ] ; then - return 0 - else - return 1 - fi -} - -exists_user() { - EXISTS=$($RUNUSER - postgres -c 'psql -t -c "select usename from pg_user where usename='"'$PGUSER'"';"') - if [ "x$EXISTS" == "x $PGUSER" ] ; then - return 0 - else - return 1 - fi -} - -postgresql_service() { - if [ -e "$SPACEWALK_TARGET" ] ; then - case $1 in - initdb) postgresql-setup initdb ;; - *) systemctl $1 postgresql ;; - esac - else - case $1 in - enable) chkconfig postgresql on ;; - *) service postgresql $1 ;; - esac - fi -} - -OPTS=$(getopt --longoptions=db:,user:,password:,standalone,help,address:,remote: -n ${0##*/} -- d:u:p:sha:r: "$@") - -if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi - -eval set -- "$OPTS" - -PGNAME="" -PGUSER="" -PGPASSWORD="" -STANDALONE=false -ADDRESS="" -REMOTE="" - -while true ; do - case "$1" in - -d|--db) - PGNAME=$2 - shift - ;; - -u|--user) - PGUSER=$2 - shift - ;; - -p|--password) - PGPASSWORD=$2 - shift - ;; - -s|--standalone) - STANDALONE=true - ;; - -a|--address) - ADDRESS=$2 - shift - ;; - -r|--remote) - REMOTE=$2 - shift - ;; - -h|--help) - help; - exit 0; - ;; - --) - shift - break - ;; - *) - echo "Internal error [$1]!" >&2 - exit 1 - ;; - esac - shift -done - -case $1 in - create) create - ;; - remove) remove - ;; - check) check - ;; - *) help - ;; -esac diff --git a/spacewalk/spacewalk-setup-postgresql/setup/defaults.d/embedded-postgresql.conf b/spacewalk/spacewalk-setup-postgresql/setup/defaults.d/embedded-postgresql.conf deleted file mode 100644 index a9db2b4c99f3..000000000000 --- a/spacewalk/spacewalk-setup-postgresql/setup/defaults.d/embedded-postgresql.conf +++ /dev/null @@ -1,5 +0,0 @@ -db-name = susemanager -db-user = susemanager -db-password = susemanager -db-host = -db-port = diff --git a/spacewalk/spacewalk-setup-postgresql/setup/postgresql.conf b/spacewalk/spacewalk-setup-postgresql/setup/postgresql.conf deleted file mode 100644 index 0ea3b819ce0f..000000000000 --- a/spacewalk/spacewalk-setup-postgresql/setup/postgresql.conf +++ /dev/null @@ -1,12 +0,0 @@ - -### spacewalk-setup-postgresql modified values -checkpoint_completion_target = 0.7 -checkpoint_segments = 8 # removed in PostgreSQL 9.5 -effective_cache_size = 1152MB -log_line_prefix = '%m ' -maintenance_work_mem = 96MB -max_connections = 600 -shared_buffers = 384MB -wal_buffers = 4MB -work_mem = 2560kB -jit = off diff --git a/spacewalk/spacewalk-setup-postgresql/spacewalk-setup-postgresql.changes b/spacewalk/spacewalk-setup-postgresql/spacewalk-setup-postgresql.changes deleted file mode 100644 index fb5e81a4e947..000000000000 --- a/spacewalk/spacewalk-setup-postgresql/spacewalk-setup-postgresql.changes +++ /dev/null @@ -1,191 +0,0 @@ -------------------------------------------------------------------- -Mon Oct 14 15:54:12 CEST 2024 - rosuna@suse.com - -- version 5.1.1-0 - * Bump version to 5.1.0 - -------------------------------------------------------------------- -Tue Jan 16 08:17:58 CET 2024 - jgonzalez@suse.com - -- version 5.0.1-1 - * Bump version to 5.0.0 - -------------------------------------------------------------------- -Fri Dec 15 17:23:13 CET 2023 - rosuna@suse.com - -- version 4.4.3-1 - * Disable postgres JIT - * Fix postgres require macros to be installable introducing - postgresql_version_min and postgresql_version_max to limit - allowed postgresql version - * Allow postgresql version dependency to be set in project config - -------------------------------------------------------------------- -Mon Sep 18 14:48:45 CEST 2023 - rosuna@suse.com - -- version 4.4.2-1 - * drop not required dependencies - -------------------------------------------------------------------- -Wed Sep 28 11:03:22 CEST 2022 - jgonzalez@suse.com - -- version 4.4.1-1 - * Bump version to 4.4.0 - -------------------------------------------------------------------- -Tue Apr 19 12:10:12 CEST 2022 - jgonzalez@suse.com - -- version 4.3.4-1 - * sort pg_hba.conf file (bsc#1198154) - -------------------------------------------------------------------- -Tue Feb 15 10:04:57 CET 2022 - jgonzalez@suse.com - -- version 4.3.3-1 - * Switch md5 to scram-sha-256 hashing algorithm - -------------------------------------------------------------------- -Tue Jan 18 14:00:36 CET 2022 - jgonzalez@suse.com - -- version 4.3.2-1 - * Require PostgreSQL 14 on SUSE Linux Enterprise 15 SP4 - * cleanup unused dependencies - -------------------------------------------------------------------- -Mon Aug 09 10:40:48 CEST 2021 - jgonzalez@suse.com - -- version 4.3.1-1 -- Bump version to 4.3.0 - -------------------------------------------------------------------- -Wed May 05 16:38:51 CEST 2021 - jgonzalez@suse.com - -- version 4.2.2-1 -- change deprecated path /var/run into /run for systemd (bsc#1185059) - -------------------------------------------------------------------- -Fri Sep 18 11:45:29 CEST 2020 - jgonzalez@suse.com - -- version 4.2.1-1 -- Update package version to 4.2.0 - -------------------------------------------------------------------- -Wed Nov 27 16:49:34 CET 2019 - jgonzalez@suse.com - -- version 4.1.1-1 -- force UTF8 charset for database -- Bump version to 4.1.0 (bsc#1154940) - -------------------------------------------------------------------- -Wed May 15 15:19:11 CEST 2019 - jgonzalez@suse.com - -- version 4.0.3-1 -- SPEC cleanup - -------------------------------------------------------------------- -Fri Oct 26 10:44:11 CEST 2018 - jgonzalez@suse.com - -- version 4.0.2-1 -- Add Uyuni URL to package - -------------------------------------------------------------------- -Fri Aug 10 15:31:53 CEST 2018 - jgonzalez@suse.com - -- version 4.0.1-1 -- Bump version to 4.0.0 (bsc#1104034) -- Fix copyright for the package specfile (bsc#1103696) - -------------------------------------------------------------------- -Mon Mar 26 09:08:14 CEST 2018 - jgonzalez@suse.com - -- version 2.8.4.1-1 -- Sync with upstream (bsc#1083294) -- Make spacewalk-setup-postgres run on postgres10+ - -------------------------------------------------------------------- -Mon Mar 05 08:57:18 CET 2018 - jgonzalez@suse.com - -- version 2.8.2.2-1 -- remove clean section from spec (bsc#1083294) - -------------------------------------------------------------------- -Wed Feb 28 09:57:51 CET 2018 - jgonzalez@suse.com - -- version 2.8.2.1-1 -- Sync with upstream - -------------------------------------------------------------------- -Wed Jan 17 10:48:52 CET 2018 - jgonzalez@suse.com - -- version 2.8.1.1-1 -- Bumping package versions for 2.8. - -------------------------------------------------------------------- -Wed May 03 16:40:57 CEST 2017 - michele.bologna@suse.com - -- version 2.7.2.1-1 -------------------------------------------------------------------- -Mon Apr 03 14:43:18 CEST 2017 - mc@suse.de - -- version 2.7.1.3-1 -- fix isSUSE: command not found - -------------------------------------------------------------------- -Mon Mar 06 16:16:54 CET 2017 - mc@suse.de - -- version 2.7.1.2-1 -- Updated links to github in spec files - -------------------------------------------------------------------- -Tue Feb 07 17:47:44 CET 2017 - michele.bologna@suse.com - -- version 2.7.1.1-1 -- Align with upstream versioning -------------------------------------------------------------------- -Wed Jan 11 16:39:47 CET 2017 - michele.bologna@suse.com - -- version 2.7.0.1-1 -- Bumping package versions for 2.7. - -------------------------------------------------------------------- -Thu Dec 10 17:56:36 CET 2015 - mc@suse.de - -- version 2.5.0.2-1 -- remove creation of pltclu language in spacewalk-setup-postgresql -- get rid of pltcl by disabling upstream logging. - -------------------------------------------------------------------- -Wed Oct 07 17:08:24 CEST 2015 - mc@suse.de - -- version 2.5.0.1-1 - -------------------------------------------------------------------- -Tue Feb 03 13:20:10 CET 2015 - mc@suse.de - -- version 2.1.4.4-1 -- Getting rid of Tabs and trailing spaces - -------------------------------------------------------------------- -Tue May 06 15:26:03 CEST 2014 - mc@suse.de - -- version 2.1.4.3-1 -- automatically select utf8 for db character encoding - -------------------------------------------------------------------- -Thu Mar 27 10:17:48 CET 2014 - fcastelli@suse.com - -- version 2.1.4.2-1 -- spacewalk-setup-postgresql requires lsof - -------------------------------------------------------------------- -Tue Dec 10 15:36:07 CET 2013 - mc@suse.de - -- version 2.1.4.1-1 -- Require postgresql-pltcl >= 8.4 -- switch to 2.1 - -------------------------------------------------------------------- -Fri Jun 7 13:23:24 CEST 2013 - mc@suse.de - -- initial release - diff --git a/spacewalk/spacewalk-setup-postgresql/spacewalk-setup-postgresql.spec b/spacewalk/spacewalk-setup-postgresql/spacewalk-setup-postgresql.spec deleted file mode 100644 index f9b4dd4721e2..000000000000 --- a/spacewalk/spacewalk-setup-postgresql/spacewalk-setup-postgresql.spec +++ /dev/null @@ -1,75 +0,0 @@ -# -# spec file for package spacewalk-setup-postgresql -# -# Copyright (c) 2024 SUSE LLC -# Copyright (c) 2008-2018 Red Hat, Inc. -# -# All modifications and additions to the file contributed by third parties -# remain the property of their copyright owners, unless otherwise agreed -# upon. The license for this file, and modifications and additions to the -# file, is the same license as for the pristine package itself (unless the -# license for the pristine package is not an Open Source License, in which -# case the license is the MIT License). An "Open Source License" is a -# license that conforms to the Open Source Definition (Version 1.9) -# published by the Open Source Initiative. - -# Please submit bugfixes or comments via https://bugs.opensuse.org/ -# - - -Name: spacewalk-setup-postgresql -Version: 5.1.1 -Release: 0 -Summary: Tools to setup embedded PostgreSQL database for Spacewalk -License: GPL-2.0-only -# FIXME: use correct group or remove it, see "https://en.opensuse.org/openSUSE:Package_group_guidelines" -Group: Applications/System -URL: https://github.com/uyuni-project/uyuni -Source0: https://github.com/spacewalkproject/spacewalk/archive/%{name}-%{version}.tar.gz -%if 0%{?suse_version} -# Actual version set by prjconf, default is 14 -%{!?postgresql_version_min: %global postgresql_version_min 14} -%{!?postgresql_version_max: %global postgresql_version_max 15} -Requires: postgresql-contrib-implementation >= %{postgresql_version_min} -Requires: postgresql-server-implementation >= %{postgresql_version_min} -Conflicts: postgresql-contrib-implementation > %{postgresql_version_max} -Conflicts: postgresql-server-implementation > %{postgresql_version_max} -%else -Requires: postgresql-contrib >= 12 -Requires: postgresql-server > 12 -%endif -Requires: lsof -BuildArch: noarch - -%description -Script, which will setup PostgreSQL database for Spacewalk. - -%prep -%setup -q - -%build - -%install -install -d -m 755 %{buildroot}%{_bindir} -install -m 0755 bin/* %{buildroot}%{_bindir} -install -d -m 755 %{buildroot}%{_datadir}/spacewalk/setup/defaults.d -install -m 0644 setup/defaults.d/* %{buildroot}%{_datadir}/spacewalk/setup/defaults.d/ -install -m 0644 setup/*.conf %{buildroot}%{_datadir}/spacewalk/setup/ - -%files -%defattr(-,root,root,-) -%license LICENSE -%dir %{_datadir}/spacewalk -%dir %{_datadir}/spacewalk/setup -%dir %{_datadir}/spacewalk/setup/defaults.d -%attr(755,root,root) %{_bindir}/spacewalk-setup-postgresql -#%{_mandir}/man1/* -%{_datadir}/spacewalk/setup/defaults.d/* -%{_datadir}/spacewalk/setup/*.conf -%if 0%{?suse_version} -%dir %{_datadir}/spacewalk -%dir %{_datadir}/spacewalk/setup -%dir %{_datadir}/spacewalk/setup/defaults.d -%endif - -%changelog diff --git a/spacewalk/uyuni-setup-reportdb/bin/uyuni-setup-reportdb b/spacewalk/uyuni-setup-reportdb/bin/uyuni-setup-reportdb index dfa341cd7caa..ae7c2cdb9424 100755 --- a/spacewalk/uyuni-setup-reportdb/bin/uyuni-setup-reportdb +++ b/spacewalk/uyuni-setup-reportdb/bin/uyuni-setup-reportdb @@ -173,22 +173,6 @@ create() { if [ ! -d "$PG_DATA/base" ]; then PGHOME=$(getent passwd postgres | awk -F: '{print $6}') - if test -x /usr/sbin/selinuxenabled && /usr/sbin/selinuxenabled; then - SEMODE=$(/usr/sbin/getenforce) - if [ "$SEMODE" = 'Permissive' -o "$SEMODE" = 'Enforcing' ]; then - RCONOUT=$(/sbin/restorecon -Rnv $PGHOME) - if [ -n "$RCONOUT" ]; then - echo - echo "The directory \"$PGHOME\" does not seem to have correct SELinux context." - echo - echo "Please fix the SELinux context by running:" - echo - echo " restorecon -Rv $PGHOME" - echo - exit 1 - fi - fi - fi echo -e 'LC_CTYPE=en_US.UTF-8\nexport LC_CTYPE' >$PGHOME/.i18n postgresql_service initdb fi @@ -220,8 +204,6 @@ EOF echo "$ADDRESS"|grep -q '127.0.0.1\|*' || ADDRESS="$ADDRESS, 127.0.0.1" postgres_reconfig "listen_addresses" "'$ADDRESS'" - sysctl kernel.shmmax | ( read v v v ; LIMIT=5000000000 ; if (("$v"0 < $LIMIT )) ; then sysctl "kernel.shmmax=$LIMIT" >> /etc/sysctl.conf ; fi ) - if $STANDALONE; then sed -i 's/^\([^#].*\)$/### next line has been commented out by uyuni-setup-reportdb: ###\n##\1/ ' $PG_HBA pg_hba_set "local" "all" "all" "" "peer" @@ -278,8 +260,10 @@ EOF chmod 640 $RHN_CONF if [ $EXTERNALDB = "0" ] ; then - postgresql_service status >& /dev/null && postgresql_service stop - postgresql_service start + if test -e $PG_PIDFILE; then + $RUNUSER postgres -c "/usr/share/postgresql/postgresql-script stop" + fi + $RUNUSER postgres -c "/usr/share/postgresql/postgresql-script start" if $LSOF /proc > /dev/null ; then while [ -f "$PG_PIDFILE" ] ; do @@ -292,21 +276,21 @@ EOF if ! exists_db ; then if [ $EXTERNALDB = "0" ] ; then - $RUNUSER - postgres -c "createdb -E UTF8 '$PGNAME'" + $RUNUSER postgres -c "createdb -E UTF8 '$PGNAME'" else echo "CREATE DATABASE $PGNAME ENCODING = UTF8 ;" | ( export PGPASSWORD=$EXTERNALDB_ADMIN_PASS; exec psql -h $HOST -U $EXTERNALDB_ADMIN_USER) fi fi if ! exists_plpgsql ; then if [ $EXTERNALDB = "0" ] ; then - EXTENSION=$($RUNUSER - postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS plpgsql;" -d '$PGNAME'') + EXTENSION=$($RUNUSER postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS plpgsql;" -d '$PGNAME'') else echo "CREATE EXTENSION IF NOT EXISTS plpgsql;" | ( export PGPASSWORD=$EXTERNALDB_ADMIN_PASS; exec psql -h $HOST -U $EXTERNALDB_ADMIN_USER -d $PGNAME) fi fi if ! exists_user ; then if [ $EXTERNALDB = "0" ] ; then - $RUNUSER - postgres -c "yes '$PGPASSWORD' | createuser -P -sDR '$PGUSER'" 2>/dev/null + $RUNUSER postgres -c "yes '$PGPASSWORD' | createuser -P -sDR '$PGUSER'" 2>/dev/null else if [[ -n $EXTERNALDB_PROVIDER && "${EXTERNALDB_PROVIDER,,}" == "aws" ]] ; then echo "CREATE ROLE $PGUSER PASSWORD '$PGPASSWORD' NOCREATEDB NOCREATEROLE INHERIT LOGIN;" | ( export PGPASSWORD=$EXTERNALDB_ADMIN_PASS; exec psql -h $HOST -U $EXTERNALDB_ADMIN_USER) @@ -336,14 +320,14 @@ remove() { fi if exists_db ; then if [ $EXTERNALDB = "0" ] ; then - $RUNUSER - postgres -c "dropdb '$PGNAME'" + $RUNUSER postgres -c "dropdb '$PGNAME'" else echo "DROP DATABASE $PGNAME;" | ( export PGPASSWORD=$EXTERNALDB_ADMIN_PASS; exec psql -h $HOST -U $EXTERNALDB_ADMIN_USER) fi fi if exists_user ; then if [ $EXTERNALDB = "0" ] ; then - $RUNUSER - postgres -c "dropuser '$PGUSER'" + $RUNUSER postgres -c "dropuser '$PGUSER'" else echo "DROP ROLE $PGUSER;" | ( export PGPASSWORD=$EXTERNALDB_ADMIN_PASS; exec psql -h $HOST -U $EXTERNALDB_ADMIN_USER) fi @@ -389,7 +373,7 @@ check() { } is_postgres10() { - NUM=$($RUNUSER - postgres -c 'psql -t -c "SHOW server_version_num;"') + NUM=$($RUNUSER postgres -c 'psql -t -c "SHOW server_version_num;"') if (( $NUM > 100000 )) ; then return 0 else @@ -399,7 +383,7 @@ is_postgres10() { exists_db() { if [ $EXTERNALDB = "0" ] ; then - EXISTS=$($RUNUSER - postgres -c 'psql -t -c "select datname from pg_database where datname='"'$PGNAME'"';"') + EXISTS=$($RUNUSER postgres -c 'psql -t -c "select datname from pg_database where datname='"'$PGNAME'"';"') else EXISTS=$(echo "select datname from pg_database where datname='$PGNAME';" | (export PGPASSWORD=$EXTERNALDB_ADMIN_PASS; exec psql -t -U $EXTERNALDB_ADMIN_USER -h $HOST )) fi @@ -412,7 +396,7 @@ exists_db() { exists_plpgsql() { if [ $EXTERNALDB = "0" ] ; then - EXISTS=$($RUNUSER - postgres -c 'psql -At -c "select lanname from pg_catalog.pg_language where lanname='"'plpgsql'"';"'" $PGNAME") + EXISTS=$($RUNUSER postgres -c 'psql -At -c "select lanname from pg_catalog.pg_language where lanname='"'plpgsql'"';"'" $PGNAME") else EXISTS=$(echo "select lanname from pg_catalog.pg_language where lanname='plpgsql';" | (export PGPASSWORD=$EXTERNALDB_ADMIN_PASS; exec psql -t -U $EXTERNALDB_ADMIN_USER -h $HOST )) fi @@ -425,7 +409,7 @@ exists_plpgsql() { exists_user() { if [ $EXTERNALDB = "0" ] ; then - EXISTS=$($RUNUSER - postgres -c 'psql -t -c "select usename from pg_user where usename='"'$PGUSER'"';"') + EXISTS=$($RUNUSER postgres -c 'psql -t -c "select usename from pg_user where usename='"'$PGUSER'"';"') else EXISTS=$(echo "select usename from pg_user where usename='$PGUSER';" | (export PGPASSWORD=$EXTERNALDB_ADMIN_PASS; exec psql -t -U $EXTERNALDB_ADMIN_USER -h $HOST )) fi @@ -473,15 +457,13 @@ postgresql_service() { initdb) if isSUSE ; then # the start script initialize the DB - if $LOCAL ; then - $RUNUSER - postgres -c "/usr/share/postgresql/postgresql-script start" - else - systemctl start postgresql + if ! test -e $PG_PIDFILE; then + $RUNUSER postgres -c "/usr/share/postgresql/postgresql-script start" fi - else + else ${POSTGRESQL_SERVICE}-setup initdb - fi - ;; + fi + ;; status) if $LOCAL ; then pgrep -x postgresql >/dev/null && return 1 || return 0 @@ -495,19 +477,15 @@ postgresql_service() { fi ;; *) - if $LOCAL ; then - echo ">> $1" - $RUNUSER - postgres -c "/usr/share/postgresql/postgresql-script $1" - else - systemctl $1 ${POSTGRESQL_SERVICE} - fi + echo ">> $1" + $RUNUSER postgres -c "/usr/share/postgresql/postgresql-script $1" ;; esac } test_postgres_user() { set +e - su - postgres -c /bin/true + su postgres -c /bin/true if [ $? != "0" ] ; then echo "Cannot use postgres user. Terminating" >&2 exit 1 diff --git a/spacewalk/uyuni-setup-reportdb/uyuni-setup-reportdb.changes.cbosdo.systemd-free-setup b/spacewalk/uyuni-setup-reportdb/uyuni-setup-reportdb.changes.cbosdo.systemd-free-setup new file mode 100644 index 000000000000..f19accc4f146 --- /dev/null +++ b/spacewalk/uyuni-setup-reportdb/uyuni-setup-reportdb.changes.cbosdo.systemd-free-setup @@ -0,0 +1 @@ +- Remove the need for a running systemd during setup diff --git a/susemanager-utils/testing/docker/scripts/reset_pgsql_database.sh b/susemanager-utils/testing/docker/scripts/reset_pgsql_database.sh index 96fb189be1d9..913ab3665bca 100755 --- a/susemanager-utils/testing/docker/scripts/reset_pgsql_database.sh +++ b/susemanager-utils/testing/docker/scripts/reset_pgsql_database.sh @@ -21,7 +21,7 @@ su - postgres -c "/usr/lib/postgresql/bin/pg_ctl start" touch /var/lib/rhn/rhn-satellite-prep/etc/rhn/rhn.conf touch /etc/rhn/rhn.conf -spacewalk-setup --clear-db --db-only --answer-file=clear-db-answers-pgsql.txt --external-postgresql --non-interactive || { +spacewalk-setup --clear-db --db-only --answer-file=clear-db-answers-pgsql.txt || { cat /var/log/rhn/populate_db.log exit 1 } diff --git a/susemanager-utils/testing/docker/scripts/schema_migration_reportdb_test_pgsql.sh b/susemanager-utils/testing/docker/scripts/schema_migration_reportdb_test_pgsql.sh index 6b4cdb9deee9..93773aceadf7 100755 --- a/susemanager-utils/testing/docker/scripts/schema_migration_reportdb_test_pgsql.sh +++ b/susemanager-utils/testing/docker/scripts/schema_migration_reportdb_test_pgsql.sh @@ -69,7 +69,7 @@ fi # this command will fail with certificate error. This is ok, so ignore the error -spacewalk-setup --skip-initial-configuration --skip-system-version-test --skip-selinux-test --skip-fqdn-test --skip-ssl-cert-generation --skip-ssl-vhost-setup --skip-services-check --clear-db --answer-file=clear-db-answers-pgsql.txt --external-postgresql --non-interactive ||: +spacewalk-setup --skip-initial-configuration --skip-fqdn-test --skip-ssl-cert-generation --skip-ssl-vhost-setup --skip-services-check --clear-db --answer-file=clear-db-answers-pgsql.txt ||: /manager/spacewalk/uyuni-setup-reportdb/bin/uyuni-setup-reportdb remove --db reportdb --user pythia ||: /manager/spacewalk/uyuni-setup-reportdb/bin/uyuni-setup-reportdb create --db reportdb --user pythia --password spacewalk --local diff --git a/susemanager-utils/testing/docker/scripts/schema_migration_test_pgsql.sh b/susemanager-utils/testing/docker/scripts/schema_migration_test_pgsql.sh index 92a54cf2cb5e..3c533965ba7f 100755 --- a/susemanager-utils/testing/docker/scripts/schema_migration_test_pgsql.sh +++ b/susemanager-utils/testing/docker/scripts/schema_migration_test_pgsql.sh @@ -66,7 +66,7 @@ if [ -d /etc/sysconfig/rhn/postgres -a ! -e /usr/share/susemanager/db/postgres ] fi # this command will fail with certificate error. This is ok, so ignore the error -spacewalk-setup --skip-initial-configuration --skip-system-version-test --skip-selinux-test --skip-fqdn-test --skip-ssl-cert-generation --skip-ssl-vhost-setup --skip-services-check --clear-db --answer-file=clear-db-answers-pgsql.txt --external-postgresql --non-interactive ||: +spacewalk-setup --skip-initial-configuration --skip-fqdn-test --skip-ssl-cert-generation --skip-ssl-vhost-setup --skip-services-check --clear-db --answer-file=clear-db-answers-pgsql.txt ||: # this copy the latest schema from the git into the system diff --git a/susemanager/bin/mgr-setup b/susemanager/bin/mgr-setup index 6ae0b636f36b..0ae704af328e 100755 --- a/susemanager/bin/mgr-setup +++ b/susemanager/bin/mgr-setup @@ -23,35 +23,11 @@ if [ ! -n "$PRODUCT_NAME" ]; then PRODUCT_NAME="SUSE Manager" fi -DISTRIBUTION_ID="$(source /etc/os-release && echo ${ID})" -case ${DISTRIBUTION_ID} in - sles|suse-manager-server) - JVM='/usr/lib64/jvm/jre-17-openjdk/bin/java' - if [ ! -f $JVM ]; then - JVM='/usr/lib64/jvm/jre-11-openjdk/bin/java' - fi;; - opensuse|opensuse-leap) - JVM='/usr/lib64/jvm/jre-17-openjdk/bin/java' - if [ ! -f $JVM ]; then - JVM='/usr/lib64/jvm/jre-11-openjdk/bin/java' - fi;; - *) echo 'Unknown distribution!' - exit $EXIT_VALIDATION_ERROR;; -esac - if [ ! $UID -eq 0 ]; then echo "You need to be superuser (root) to run this script!" exit $EXIT_VALIDATION_ERROR fi -# ensure correct java version is being used (bsc#1049575) -echo "Asserting correct java version..." -update-alternatives --set java ${JVM} -if [ ! $? -eq 0 ]; then - echo "Failed to set ${JVM} as default java version!" - exit $EXIT_VALIDATION_ERROR -fi - if [[ -n "$TZ" ]]; then timedatectl set-timezone $TZ fi @@ -62,7 +38,6 @@ SETUP_ENV="/root/setup_env.sh" MANAGER_COMPLETE="/root/.MANAGER_SETUP_COMPLETE" LOCAL_DB=1 -DB_BACKEND="postgresql" function help() { echo " @@ -83,15 +58,13 @@ ask_input() { setup_mail () { postconf -e myhostname=$HOSTNAME - # bsc#979664 - SUSE Manager requires a working mail system - systemctl --quiet enable postfix 2>&1 - systemctl restart postfix + # No need to enable postfix: it already is } exists_db() { PGNAME=$1 if [ $EXTERNALDB = 0 ]; then - EXISTS=$(runuser - postgres -c 'psql -t -c "select datname from pg_database where datname='"'$PGNAME'"';"') + EXISTS=$(runuser postgres -c 'psql -t -c "select datname from pg_database where datname='"'$PGNAME'"';"') else EXISTS=$(echo "select datname from pg_database where datname='$PGNAME';" | (export PGPASSWORD=$EXTERNALDB_ADMIN_PASS; exec psql -t -U $EXTERNALDB_ADMIN_USER -h $MANAGER_DB_HOST)) fi @@ -104,7 +77,7 @@ exists_db() { exists_user() { if [ $EXTERNALDB = 0 ] ; then - EXISTS=$($RUNUSER - postgres -c 'psql -t -c "select usename from pg_user where usename='"'$MANAGER_USER'"';"') + EXISTS=$($RUNUSER postgres -c 'psql -t -c "select usename from pg_user where usename='"'$MANAGER_USER'"';"') else EXISTS=$(echo "select usename from pg_user where usename='$MANAGER_USER';" | (export PGPASSWORD=$EXTERNALDB_ADMIN_PASS; exec psql -t -U $EXTERNALDB_ADMIN_USER -h $MANAGER_DB_HOST)) fi @@ -117,52 +90,22 @@ exists_user() { setup_db_postgres() { if [ $EXTERNALDB = 0 ]; then - POSTGRESQLSERVICE=$(systemctl list-unit-files | grep -m 1 postgresql | cut -f1 -d. | tr -d '\n') + POSTGRESQLSERVICE=postgresql DATADIR=$(runuser -l postgres -c env | grep PGDATA | cut -f2- -d=) - systemctl --quiet enable ${POSTGRESQLSERVICE} 2>&1 - if [[ "echo $(source /etc/os-release && echo ${ID_LIKE})" != *"suse"* ]]; then - # Create the PostgreSQL data folder, should it not exist. - if [ ! -f $DATADIR/PG_VERSION ]; then - rm -Rf ${DATADIR} - POSTGRES_LANG=en_US.UTF-8 - - # Define LC_CTYPE in postgres user profile. (Used during any DB creation) - PGHOME=$(getent passwd postgres | awk -F: '{print $6}') - . $PGHOME/.i18n 2>/dev/null - if [ -z $LC_CTYPE ]; then - grep "^LC_CTYPE" $PGHOME/.i18n > /dev/null 2>&1 - if [ $? = 0 ]; then - sed -i -e "s/^LC_CTYPE.*$/LC_CTYPE=${POSTGRES_LANG}/" $PGHOME/.i18n - else - echo -e "LC_CTYPE=${POSTGRES_LANG}\nexport LC_CTYPE" >> $PGHOME/.i18n - fi - fi - - echo "Initializing PostgreSQL $VERSION at location ${DATADIR}" - # Redundant locale flag for clarity - runuser -l postgres -c "/usr/bin/initdb --locale=${POSTGRES_LANG} --auth=ident $DATADIR" &> initlog || { - echo "Initialisation failed. See $PWD/initlog ." - exit $EXIT_ERROR - } - fi - else - # Define POSTGRES_LANG in system wide config. (Used during any DB creation) - . /etc/sysconfig/postgresql - if [ -z $POSTGRES_LANG ]; then - grep "^POSTGRES_LANG" /etc/sysconfig/postgresql > /dev/null 2>&1 - if [ $? = 0 ]; then - sed -i -e "s/^POSTGRES_LANG.*$/POSTGRES_LANG=\"en_US.UTF-8\"/" /etc/sysconfig/postgresql - else - echo "POSTGRES_LANG=\"en_US.UTF-8\"" >> /etc/sysconfig/postgresql - fi + systemctl enable postgresql.service + # Define POSTGRES_LANG in system wide config. (Used during any DB creation) + . /etc/sysconfig/postgresql + if [ -z $POSTGRES_LANG ]; then + grep "^POSTGRES_LANG" /etc/sysconfig/postgresql > /dev/null 2>&1 + if [ $? = 0 ]; then + sed -i -e "s/^POSTGRES_LANG.*$/POSTGRES_LANG=\"en_US.UTF-8\"/" /etc/sysconfig/postgresql + else + echo "POSTGRES_LANG=\"en_US.UTF-8\"" >> /etc/sysconfig/postgresql fi fi - systemctl start ${POSTGRESQLSERVICE} + su postgres -c "/usr/share/postgresql/postgresql-script start" if ! exists_db $MANAGER_DB_NAME; then - # required for postgresql <= 13 before creating the user - echo "password_encryption = 'scram-sha-256'" >> ${DATADIR}/postgresql.conf - systemctl restart ${POSTGRESQLSERVICE} - su - postgres -c "createdb -E UTF8 $MANAGER_DB_NAME ; echo \"CREATE ROLE $MANAGER_USER PASSWORD '$MANAGER_PASS' SUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN;\" | psql" + su postgres -c "createdb -E UTF8 $MANAGER_DB_NAME ; echo \"CREATE ROLE $MANAGER_USER PASSWORD '$MANAGER_PASS' SUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN;\" | psql" INT_NET=$(ip -o -4 addr show up scope global | head -1 | awk '{print $4}') echo "local $MANAGER_DB_NAME postgres peer @@ -175,7 +118,7 @@ setup_db_postgres() { mv /tmp/pg_hba.conf ${DATADIR}/pg_hba.conf chmod 600 ${DATADIR}/pg_hba.conf chown postgres:postgres ${DATADIR}/pg_hba.conf - systemctl restart ${POSTGRESQLSERVICE} + su postgres -c "/usr/share/postgresql/postgresql-script reload" else echo "Database exists. Preparing for resetup. All data will be removed." fi @@ -222,7 +165,7 @@ ssl-set-email = $CERT_EMAIL ssl-config-sslvhost = Y ssl-ca-cert-expiration = 10 ssl-server-cert-expiration = 10 -db-backend=$DB_BACKEND +db-backend=postgresql db-user=$MANAGER_USER db-password=$MANAGER_PASS db-name=$MANAGER_DB_NAME @@ -272,9 +215,7 @@ scc-pass = $SCC_PASS fi fi - PARAM_DB="--external-postgresql" - - /usr/bin/spacewalk-setup --non-interactive --clear-db $PARAM_CC --answer-file=/root/spacewalk-answers $PARAM_DB + /usr/bin/spacewalk-setup --clear-db $PARAM_CC --answer-file=/root/spacewalk-answers SWRET=$? if [ "x" = "x$MANAGER_MAIL_FROM" ]; then MANAGER_MAIL_FROM="$PRODUCT_NAME ($HOSTNAME) " @@ -311,7 +252,6 @@ do_setup() { ask_input CERT_EMAIL ask_input CERT_PASS ask_input LOCAL_DB - ask_input DB_BACKEND ask_input MANAGER_DB_NAME ask_input MANAGER_DB_HOST ask_input MANAGER_DB_PORT @@ -333,15 +273,9 @@ do_setup() { ask_input REPORT_DB_CA_CERT ask_input UYUNI_FQDN fi; - if [ -z "$SYS_DB_PASS" ]; then - SYS_DB_PASS=`dd if=/dev/urandom bs=16 count=4 2> /dev/null | md5sum | cut -b 1-8` - fi if [ -z "$MANAGER_DB_NAME" ]; then MANAGER_DB_NAME="susemanager" fi - if [ -z "$DB_BACKEND" ]; then - DB_BACKEND="postgresql" - fi if [ -z "$REPORT_DB_NAME" ]; then REPORT_DB_NAME="reportdb" fi @@ -359,7 +293,7 @@ do_setup() { fi case $MANAGER_DB_HOST in - "localhost"|$(hostname -s)|$(hostname -f)|"") + "localhost"|"") EXTERNALDB=0 ;; *) EXTERNALDB=1 ;; @@ -375,9 +309,7 @@ do_setup() { check_re_install echo "Do not delete this file unless you know what you are doing!" > $MANAGER_COMPLETE setup_mail - if [ "$DB_BACKEND" = "postgresql" ]; then - setup_db_postgres - fi + setup_db_postgres setup_spacewalk @@ -438,15 +370,8 @@ done do_setup if [ "$EXTERNALDB" = "0" ]; then - /usr/sbin/spacewalk-service stop /usr/bin/smdba system-check autotuning --max_connections=400 - - # Find PostgreSQL service name. - POSTGRESQLSERVICE=$(systemctl list-unit-files | grep -m 1 postgresql | cut -f1 -d. | tr -d '\n') - systemctl restart $POSTGRESQLSERVICE fi -/usr/sbin/spacewalk-service start systemctl --quiet enable spacewalk-diskcheck.timer 2>&1 -systemctl start spacewalk-diskcheck.timer # vim: set expandtab: diff --git a/susemanager/susemanager.changes.cbosdo.systemd-free-setup b/susemanager/susemanager.changes.cbosdo.systemd-free-setup new file mode 100644 index 000000000000..f19accc4f146 --- /dev/null +++ b/susemanager/susemanager.changes.cbosdo.systemd-free-setup @@ -0,0 +1 @@ +- Remove the need for a running systemd during setup