Accepting request 624217 from Application:ERP:GNUHealth:Factory
OBS-URL: https://build.opensuse.org/request/show/624217 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/gnuhealth?expand=0&rev=26
This commit is contained in:
commit
f9c291638f
@ -6,6 +6,17 @@ How to get it running (Without reading the instructions)
|
||||
|
||||
You have already installed the package gnuhealth and found this documentation. Good.
|
||||
|
||||
As very easy and convenient way to do all required settings, log in as user root and run openSUSE-gnuhealth-setup:
|
||||
|
||||
> su
|
||||
> openSUSE-gnuhealth-setup setup
|
||||
|
||||
You can follow the proposals given, anyway, **it is not recommended to use default settings for a production environment**
|
||||
|
||||
|
||||
The above setup-program automates the steps below, which you could do as well manually, if desired.
|
||||
(If you have run openSUSE-gnuhealth-setup, the below steps are not needed additionally!)
|
||||
|
||||
1) Log in as root and start the database
|
||||
> su
|
||||
> systemctl start postgresql
|
||||
|
@ -24,7 +24,7 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
VERSION="3.2.2-openSUSE"
|
||||
VERSION="3.2.3-openSUSE"
|
||||
|
||||
TRYTON_URL="http://downloads.tryton.org"
|
||||
GNUHEALTH_URL="http://ftp.gnu.org/gnu/health"
|
||||
@ -177,17 +177,19 @@ do_backup()
|
||||
gzip "${BACKDIR}/backup_${DB}_${BACKDATE}" || bailout
|
||||
|
||||
cli_msg "INFO" "Compressing GNU Health Attachment directory" | tee -a $INFOFILE
|
||||
|
||||
tar -cvzf "${BACKDIR}/gnuhealth_${DB}_fs_backup_${BACKDATE}.tar.gz" /var/lib/tryton || bailout
|
||||
#AB - start
|
||||
BACKUP_NAME=gnuhealth_${DB}_fs_backup_${BACKDATE}.tar.gz
|
||||
# tar -cvzf "${BACKDIR}/gnuhealth_${DB}_fs_backup_${BACKDATE}.tar.gz" /var/lib/tryton || bailout
|
||||
tar -cvzf "${BACKDIR}/${BACKUP_NAME}" /var/lib/tryton || bailout
|
||||
|
||||
cli_msg "INFO" "Creating tarball with compressed DB and GNU Health Attachment directory" | tee -a $INFOFILE
|
||||
|
||||
tar -cvf "${BACKDIR}/gnuhealth_${DB}_with_fs_backup_${BACKDATE}.tar" \
|
||||
${BACKDIR}/backup_${DB}_${BACKDATE}.gz ${BACKDIR}/gnuhealth_${DB}_fs_backup_${BACKDATE}.tar.gz \
|
||||
${BACKDIR}/backup_${DB}_${BACKDATE}.gz ${BACKDIR}/$BACKUP_NAME} \
|
||||
|| bailout
|
||||
|
||||
cli_msg "INFO" "Backup Successful" | tee -a $INFOFILE
|
||||
|
||||
cli_msg "INFO" "Backup successfully written to ${BACKDIR}/${BACKUP_NAME}" | tee -a $INFOFILE
|
||||
#AB - END
|
||||
#Remove lock file
|
||||
rm $LOCKFILE
|
||||
|
||||
|
@ -1,3 +1,15 @@
|
||||
-------------------------------------------------------------------
|
||||
Tue Jul 17 07:19:15 UTC 2018 - axel.braun@gmx.de
|
||||
|
||||
- openSUSE-gnuhealth-setup: User tryton set to SUPERUSER
|
||||
Documentation updated
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Jun 20 09:17:23 UTC 2018 - axel.braun@gmx.de
|
||||
|
||||
- gnuhealth-control: added info about backup file
|
||||
openSUSE-gnuhealth-setup added
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Jun 5 12:13:54 UTC 2018 - axel.braun@gmx.de
|
||||
|
||||
|
@ -34,11 +34,12 @@ Source1: GNUHealth.README.SUSE
|
||||
Source2: gnuhealth-control
|
||||
Source3: gnuhealth.service
|
||||
Source4: gnuhealth-webdav@.service
|
||||
Source5: openSUSE-gnuhealth-setup
|
||||
|
||||
BuildArch: noarch
|
||||
|
||||
Summary: A Health and Hospital Information System
|
||||
License: GPL-3.0+
|
||||
License: GPL-3.0-or-later
|
||||
Group: Productivity/Office/Management
|
||||
|
||||
Requires: proteus
|
||||
@ -118,6 +119,7 @@ done
|
||||
|
||||
mkdir -p -m 755 %{buildroot}%{_bindir}
|
||||
install -p -m 755 gnuhealth-control %{buildroot}%{_bindir}/gnuhealth-control
|
||||
install -p -m 755 %{S:5} %{buildroot}%{_bindir}/openSUSE-gnuhealth-setup
|
||||
|
||||
mkdir -p $RPM_BUILD_ROOT%{_unitdir}
|
||||
install -p -m 644 %{SOURCE3} $RPM_BUILD_ROOT%{_unitdir}/%{name}.service
|
||||
@ -152,6 +154,7 @@ EOF
|
||||
%files
|
||||
%defattr(744,root,root)
|
||||
%{_bindir}/gnuhealth-control
|
||||
%{_bindir}/openSUSE-gnuhealth-setup
|
||||
%{_unitdir}/%{name}.service
|
||||
%{_unitdir}/%{name}-webdav@.service
|
||||
%defattr(-,root,root)
|
||||
|
330
openSUSE-gnuhealth-setup
Normal file
330
openSUSE-gnuhealth-setup
Normal file
@ -0,0 +1,330 @@
|
||||
#!/bin/bash
|
||||
|
||||
# GNU Health installation script for openSUSE
|
||||
# Version agnostic to GNU Health
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# GNU Health Installer for openSUSE
|
||||
#
|
||||
# Copyright (C) 2018 Axel Braun <abraun@gnusolidario.org>
|
||||
#
|
||||
# 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Change log
|
||||
#-----------------------------------------------------------------------------
|
||||
# V 0.2 20180617 Axel Replace tryton with ${DB_USER}
|
||||
# V 0.3 20180712 Axel Set user 'tryton' to superuser (otherwise installation of DEMO-DB fails)
|
||||
# V 0.32 20180720 Axel Warning for production use added
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Variables declaration
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
#GNU Health installer for openSUSE version
|
||||
VERSION="0.31"
|
||||
|
||||
# Colors constants
|
||||
NONE="$(tput sgr0)"
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="\n$(tput setaf 3)"
|
||||
WHITE="\n$(tput setaf 7)"
|
||||
|
||||
# Params
|
||||
#ROOT_PW="root"
|
||||
DB_NAME="GNUHEALTH"
|
||||
DB_ADMIN_PWD="admin"
|
||||
DB_USER="tryton"
|
||||
DB_CONFIG="/var/lib/pgsql/data/pg_hba.conf"
|
||||
GH_START="y"
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Functions
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
message()
|
||||
{
|
||||
local UTC="$(date -u +'%Y-%m-%d %H:%M:%S')"
|
||||
|
||||
case $1 in
|
||||
ERROR ) echo -e "\e[00;31m${UTC} [ERROR] $2\e[00m";;
|
||||
WARNING ) echo -e "\e[0;33m${UTC} [WARNING] $2\e[m" ;;
|
||||
INFO ) echo -e "\e[0;36m${UTC} [INFO] $2\e[m" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
help()
|
||||
{
|
||||
cat << EOF
|
||||
|
||||
This is GNU Health Setup for openSUSE ${VERSION}
|
||||
|
||||
usage: `basename $0` command
|
||||
|
||||
Command:
|
||||
|
||||
version : Show version
|
||||
setup : Setup a GNU Health server
|
||||
help : shows this message
|
||||
|
||||
EOF
|
||||
exit 0
|
||||
}
|
||||
|
||||
show_version () {
|
||||
case $1 in
|
||||
version) message "INFO" "This is is GNU Health setup for openSUSE V ${VERSION}"; exit 0;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
bailout() {
|
||||
message "INFO" "Bailing out !"
|
||||
message "INFO" "Cleaning up temporary file"
|
||||
rm -rf /tmp/pw
|
||||
# if [ -e ${BASEDIR}/.installation_ok ];then
|
||||
# message "WARNING" "Previous successful installation found. NOT removing base dir at ${BASEDIR}"
|
||||
# else
|
||||
# message "INFO" "removing base dir at ${BASEDIR}"
|
||||
# rm -rf ${BASEDIR}
|
||||
# fi
|
||||
exit 1
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# go-ahead: perform update
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
go_ahead() {
|
||||
|
||||
# login as root, start postgres
|
||||
|
||||
echo "Starting database...."
|
||||
|
||||
systemctl start postgresql || bailout
|
||||
|
||||
echo "Database started"
|
||||
|
||||
# su -postgres || bailout
|
||||
#then as postgres, and change parameter
|
||||
|
||||
echo "Changing postgres trust method"
|
||||
|
||||
sudo -u postgres sed -i -e 's/\(\(local\|host\).*all.*all.*\)\(peer\|ident\)/\1trust/g' ${DB_CONFIG} || bailout
|
||||
|
||||
echo "Postgres trust method changed"
|
||||
|
||||
echo "Create database user"
|
||||
#create user
|
||||
sudo -u postgres psql -c "CREATE USER ${DB_USER} WITH SUPERUSER;"
|
||||
|
||||
echo "Database user created"
|
||||
|
||||
echo "Creating database ${DB_NAME}"
|
||||
# create database
|
||||
sudo -u postgres createdb ${DB_NAME} --encoding='UTF8' --owner=${DB_USER} || bailout
|
||||
|
||||
echo "Database created"
|
||||
#exit as postgres
|
||||
#exit
|
||||
|
||||
echo "Restarting database"
|
||||
|
||||
systemctl restart postgresql || bailout
|
||||
|
||||
# login as user tryton
|
||||
#su tryton -s /bin/bash
|
||||
|
||||
echo "Initializing database - this may take a while"
|
||||
|
||||
echo ${DB_ADMIN_PWD} > /tmp/pw || bailout
|
||||
|
||||
sudo -u tryton env TRYTONPASSFILE=/tmp/pw trytond-admin -c /etc/tryton/trytond.conf --all -d ${DB_NAME} --password || bailout
|
||||
|
||||
rm /tmp/pw || bailout
|
||||
|
||||
|
||||
if [ $GH_START = "y" ]; then
|
||||
echo "Enabling GNU Health at boot time"
|
||||
|
||||
systemctl enable postgresql
|
||||
systemctl enable gnuhealth
|
||||
|
||||
fi
|
||||
|
||||
echo "All done"
|
||||
message "WARNING" "Please review your setup before using the system in production!"
|
||||
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Call user parameter
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
get_root_pw() {
|
||||
Y=''
|
||||
read -p "Please enter root-password [$ROOT_PW] " Y
|
||||
|
||||
if [ ! -e $Y ]; then
|
||||
ROOT_PW=$Y
|
||||
fi
|
||||
message "INFO" "root-password is $ROOT_PW"
|
||||
}
|
||||
|
||||
get_db_name() {
|
||||
Y=''
|
||||
read -p "Please enter name for new database [$DB_NAME] " Y
|
||||
if [ ! -e $Y ]; then
|
||||
DB_NAME=$Y
|
||||
fi
|
||||
message "INFO" "DB-Name is $DB_NAME"
|
||||
}
|
||||
|
||||
get_db_admin() {
|
||||
Y=''
|
||||
read -p "Please enter admin-password for new database [$DB_ADMIN_PWD] " Y
|
||||
if [ ! -e $Y ]; then
|
||||
DB_ADMIN_PWD=$Y
|
||||
fi
|
||||
message "INFO" "DB Admin password is $DB_ADMIN_PWD"
|
||||
}
|
||||
|
||||
get_db_user() {
|
||||
Y=''
|
||||
read -p "Please enter database user [$DB_USER] " Y
|
||||
if [ ! -e $Y ]; then
|
||||
DB_USER=$Y
|
||||
fi
|
||||
message "INFO" "DB User is $DB_USER"
|
||||
}
|
||||
|
||||
get_db_file() {
|
||||
Y=''
|
||||
read -p "Please enter database config file [$DB_CONFIG] " Y
|
||||
if [ ! -e $Y ]; then
|
||||
DB_CONFIG=$Y
|
||||
fi
|
||||
message "INFO" "DB config path & file $DB_CONFIG"
|
||||
}
|
||||
|
||||
get_GH_start() {
|
||||
Y=''
|
||||
read -p "Shall GNU Health start automatically? [$GH_START] " Y
|
||||
if [ ! -e $Y ]; then
|
||||
GH_START=$Y
|
||||
fi
|
||||
message "INFO" "GNU Health start at boot $GH_START"
|
||||
}
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# verify input
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
verify_input() {
|
||||
echo ;
|
||||
message "INFO" "DB Name is ..............$DB_NAME"
|
||||
message "INFO" "DB Admin password is ....$DB_ADMIN_PWD"
|
||||
message "INFO" "DB User is ..............$DB_USER"
|
||||
message "INFO" "DB config path & file is $DB_CONFIG"
|
||||
message "INFO" "GNU Health start at boot $GH_START"
|
||||
read -p "Are these values correct? [y]es/[n]o/[a]bort " VAL
|
||||
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Install
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
setup() {
|
||||
|
||||
# check is it runs as root
|
||||
wai=`whoami`
|
||||
|
||||
if [ $wai != "root" ]; then
|
||||
message "ERROR" " This script must run as user 'root'"
|
||||
bailout
|
||||
fi
|
||||
|
||||
VAL="n"
|
||||
message "INFO" "Starting GNU Health setup for openSUSE V ${VERSION} ..."
|
||||
message "INFO" "If the value displayed is OK, just hit <ENTER> to confirm"
|
||||
|
||||
while [ ${VAL} != "y" ]; do
|
||||
# (1) Get root password
|
||||
# get_root_pw
|
||||
|
||||
# (2) get Database name
|
||||
get_db_name
|
||||
|
||||
# (3) change login
|
||||
get_db_admin
|
||||
|
||||
message "WARNING" "Change the following parameter only if you know what you are doing..."
|
||||
|
||||
# (4) DB user
|
||||
get_db_user
|
||||
|
||||
# (5) DB config file and path
|
||||
get_db_file
|
||||
|
||||
# (6) enable GNUHealth at start?
|
||||
get_GH_start
|
||||
|
||||
# (7) check if all are valid
|
||||
verify_input
|
||||
|
||||
# request input until all is OK:
|
||||
if [ -e ${VAL} ]; then
|
||||
message "ERROR" "Please enter y, n or a"
|
||||
verify_input
|
||||
else
|
||||
|
||||
if [ ${VAL} = "y" ]; then
|
||||
go_ahead
|
||||
exit 0
|
||||
fi
|
||||
if [ ${VAL} = "a" ]; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Parse command line
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
parse_command_line()
|
||||
{
|
||||
if [ $# -eq 0 ]; then
|
||||
help
|
||||
fi
|
||||
|
||||
case $1 in
|
||||
version) show_version $@;;
|
||||
update-deps) install_python_dependencies $@;;
|
||||
setup) setup $@;;
|
||||
help) help;;
|
||||
*) echo $1: Unrecognized command; exit 1;;
|
||||
esac
|
||||
}
|
||||
|
||||
parse_command_line "$@"
|
322
openSUSE_gnuhealth_setup
Normal file
322
openSUSE_gnuhealth_setup
Normal file
@ -0,0 +1,322 @@
|
||||
#!/bin/bash
|
||||
|
||||
# GNU Health installation script for openSUSE
|
||||
# Version agnostic to GNU Health
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# GNU Health Installer for openSUSE
|
||||
#
|
||||
# Copyright (C) 2018 Axel Braun <abraun@gnusolidario.org>
|
||||
#
|
||||
# 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Variables declaration
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
#GNU Health installer for openSUSE version
|
||||
VERSION="0.1"
|
||||
|
||||
# Colors constants
|
||||
NONE="$(tput sgr0)"
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="\n$(tput setaf 3)"
|
||||
WHITE="\n$(tput setaf 7)"
|
||||
|
||||
# Params
|
||||
#ROOT_PW="root"
|
||||
DB_NAME="GNUHEALTH"
|
||||
DB_ADMIN_PWD="admin"
|
||||
DB_USER="tryton"
|
||||
DB_CONFIG="/var/lib/pgsql/data/pg_hba.conf"
|
||||
GH_START="y"
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Functions
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
message()
|
||||
{
|
||||
local UTC="$(date -u +'%Y-%m-%d %H:%M:%S')"
|
||||
|
||||
case $1 in
|
||||
ERROR ) echo -e "\e[00;31m${UTC} [ERROR] $2\e[00m";;
|
||||
WARNING ) echo -e "\e[0;33m${UTC} [WARNING] $2\e[m" ;;
|
||||
INFO ) echo -e "\e[0;36m${UTC} [INFO] $2\e[m" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
help()
|
||||
{
|
||||
cat << EOF
|
||||
|
||||
This is GNU Health Setup for openSUSE ${VERSION}
|
||||
|
||||
usage: `basename $0` command
|
||||
|
||||
Command:
|
||||
|
||||
version : Show version
|
||||
setup : Setup a GNU Health server
|
||||
help : shows this message
|
||||
|
||||
EOF
|
||||
exit 0
|
||||
}
|
||||
|
||||
show_version () {
|
||||
case $1 in
|
||||
version) message "INFO" "This is is GNU Health setup for openSUSE V ${VERSION}"; exit 0;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
bailout() {
|
||||
message "INFO" "Bailing out !"
|
||||
message "INFO" "Cleaning up temporary file"
|
||||
rm -rf /tmp/pw
|
||||
# if [ -e ${BASEDIR}/.installation_ok ];then
|
||||
# message "WARNING" "Previous successful installation found. NOT removing base dir at ${BASEDIR}"
|
||||
# else
|
||||
# message "INFO" "removing base dir at ${BASEDIR}"
|
||||
# rm -rf ${BASEDIR}
|
||||
# fi
|
||||
exit 1
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# go-ahead: perform update
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
go_ahead() {
|
||||
|
||||
# login as root, start postgres
|
||||
|
||||
echo "Starting database...."
|
||||
|
||||
systemctl start postgresql || bailout
|
||||
|
||||
echo "Database started"
|
||||
|
||||
# su -postgres || bailout
|
||||
#then as postgres, and change parameter
|
||||
|
||||
echo "Changing postgres trust method"
|
||||
|
||||
sudo -u postgres sed -i -e 's/\(\(local\|host\).*all.*all.*\)\(peer\|ident\)/\1trust/g' ${DB_CONFIG} || bailout
|
||||
|
||||
echo "Postgres trust method changed"
|
||||
|
||||
echo "Create database user"
|
||||
#create user
|
||||
sudo -u postgres psql -c "CREATE USER tryton WITH CREATEDB;" || bailout
|
||||
|
||||
echo "Database user created"
|
||||
|
||||
echo "Creating database ${DB_NAME}"
|
||||
# create database
|
||||
sudo -u postgres createdb ${DB_NAME} --encoding='UTF8' --owner=tryton || bailout
|
||||
|
||||
echo "Database created"
|
||||
#exit as postgres
|
||||
#exit
|
||||
|
||||
echo "Restarting database"
|
||||
|
||||
systemctl restart postgresql || bailout
|
||||
|
||||
# login as user tryton
|
||||
#su tryton -s /bin/bash
|
||||
|
||||
echo "Initializing database - this may take a while"
|
||||
|
||||
echo ${DB_ADMIN_PWD} > /tmp/pw || bailout
|
||||
|
||||
sudo -u tryton env TRYTONPASSFILE=/tmp/pw trytond-admin -c /etc/tryton/trytond.conf --all -d ${DB_NAME} --password || bailout
|
||||
|
||||
rm /tmp/pw || bailout
|
||||
|
||||
|
||||
if [ $GH_START = "y" ]; then
|
||||
echo "Enabling GNU Health at boot time"
|
||||
|
||||
systemctl enable postgresql
|
||||
systemctl enable gnuhealth
|
||||
|
||||
fi
|
||||
|
||||
echo "All done"
|
||||
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Call user parameter
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
get_root_pw() {
|
||||
Y=''
|
||||
read -p "Please enter root-password [$ROOT_PW] " Y
|
||||
|
||||
if [ ! -e $Y ]; then
|
||||
ROOT_PW=$Y
|
||||
fi
|
||||
message "INFO" "root-password is $ROOT_PW"
|
||||
}
|
||||
|
||||
get_db_name() {
|
||||
Y=''
|
||||
read -p "Please enter name for new database [$DB_NAME] " Y
|
||||
if [ ! -e $Y ]; then
|
||||
DB_NAME=$Y
|
||||
fi
|
||||
message "INFO" "DB-Name is $DB_NAME"
|
||||
}
|
||||
|
||||
get_db_admin() {
|
||||
Y=''
|
||||
read -p "Please enter admin-password for new database [$DB_ADMIN_PWD] " Y
|
||||
if [ ! -e $Y ]; then
|
||||
DB_ADMIN_PWD=$Y
|
||||
fi
|
||||
message "INFO" "DB Admin password is $DB_ADMIN_PWD"
|
||||
}
|
||||
|
||||
get_db_user() {
|
||||
Y=''
|
||||
read -p "Please enter database user [$DB_USER] " Y
|
||||
if [ ! -e $Y ]; then
|
||||
DB_USER=$Y
|
||||
fi
|
||||
message "INFO" "DB User is $DB_USER"
|
||||
}
|
||||
|
||||
get_db_file() {
|
||||
Y=''
|
||||
read -p "Please enter database config file [$DB_CONFIG] " Y
|
||||
if [ ! -e $Y ]; then
|
||||
DB_CONFIG=$Y
|
||||
fi
|
||||
message "INFO" "DB config path & file $DB_CONFIG"
|
||||
}
|
||||
|
||||
get_GH_start() {
|
||||
Y=''
|
||||
read -p "Shall GNU Health start automatically? [$GH_START] " Y
|
||||
if [ ! -e $Y ]; then
|
||||
GH_START=$Y
|
||||
fi
|
||||
message "INFO" "GNU Health start at boot $GH_START"
|
||||
}
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# verify input
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
verify_input() {
|
||||
echo ;
|
||||
message "INFO" "DB Name is ..............$DB_NAME"
|
||||
message "INFO" "DB Admin password is ....$DB_ADMIN_PWD"
|
||||
message "INFO" "DB User is ..............$DB_USER"
|
||||
message "INFO" "DB config path & file is $DB_CONFIG"
|
||||
message "INFO" "GNU Health start at boot $GH_START"
|
||||
read -p "Are these values correct? [y]es/[n]o/[a]bort " VAL
|
||||
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Install
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
setup() {
|
||||
|
||||
# check is it runs as root
|
||||
wai=`whoami`
|
||||
|
||||
if [ $wai != "root" ]; then
|
||||
message "ERROR" " This script must run as user 'root'"
|
||||
bailout
|
||||
fi
|
||||
|
||||
VAL="n"
|
||||
message "INFO" "Starting GNU Health setup for openSUSE V ${VERSION} ..."
|
||||
message "INFO" "If the value displayed is OK, just hit <ENTER> to confirm"
|
||||
|
||||
while [ ${VAL} != "y" ]; do
|
||||
# (1) Get root password
|
||||
# get_root_pw
|
||||
|
||||
# (2) get Database name
|
||||
get_db_name
|
||||
|
||||
# (3) change login
|
||||
get_db_admin
|
||||
|
||||
message "WARNING" "Change the following parameter only if you know what you are doing..."
|
||||
|
||||
# (4) DB user
|
||||
get_db_user
|
||||
|
||||
# (5) DB config file and path
|
||||
get_db_file
|
||||
|
||||
# (6) enable GNUHealth at start?
|
||||
get_GH_start
|
||||
|
||||
# (7) check if all are valid
|
||||
verify_input
|
||||
|
||||
# request input until all is OK:
|
||||
if [ -e ${VAL} ]; then
|
||||
message "ERROR" "Please enter y, n or a"
|
||||
verify_input
|
||||
else
|
||||
|
||||
if [ ${VAL} = "y" ]; then
|
||||
go_ahead
|
||||
exit 0
|
||||
fi
|
||||
if [ ${VAL} = "a" ]; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Parse command line
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
parse_command_line()
|
||||
{
|
||||
if [ $# -eq 0 ]; then
|
||||
help
|
||||
fi
|
||||
|
||||
case $1 in
|
||||
version) show_version $@;;
|
||||
update-deps) install_python_dependencies $@;;
|
||||
setup) setup $@;;
|
||||
help) help;;
|
||||
*) echo $1: Unrecognized command; exit 1;;
|
||||
esac
|
||||
}
|
||||
|
||||
parse_command_line "$@"
|
Loading…
Reference in New Issue
Block a user