Skip to content

Commit

Permalink
Split setup script
Browse files Browse the repository at this point in the history
  • Loading branch information
joseivanlopez committed Dec 5, 2023
1 parent 52400fc commit b0ab5a6
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 25 deletions.
8 changes: 3 additions & 5 deletions setup-service.sh → setup-services.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#!/bin/sh -x

# Using a git checkout in the current directory,
# set up the service (backend) part of agama
# so that it can be used by
# - the web frontend (as set up by setup.sh)
# Using a git checkout in the current directory and set up the services, so that it can be used by:
# - the web frontend (as set up by setup-web.sh)
# - the CLI
# or both

# Exit on error; unset variables are an error
# Exit on error; unset variables are an error.
set -eu

MYDIR=$(realpath $(dirname $0))
Expand Down
29 changes: 29 additions & 0 deletions setup-web.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh -x

# Exit on error; unset variables are an error.
set -eu

MYDIR=$(realpath $(dirname $0))

# Helper:
# Ensure root privileges for the installation.
# In a testing container, we are root but there is no sudo.
if [ $(id --user) != 0 ]; then
SUDO=sudo
if [ $($SUDO id --user) != 0 ]; then
echo "We are not root and cannot sudo, cannot continue."
exit 1
fi
else
SUDO=""
fi

$SUDO zypper --non-interactive --gpg-auto-import-keys install \
make \
'npm>=18' \
cockpit || exit 1

$SUDO systemctl start cockpit

cd web; make devel-install; cd -
$SUDO ln -snf `pwd`/web/dist /usr/share/cockpit/agama
34 changes: 14 additions & 20 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/sh

# This script sets up the development environment without installing any
# package. This script is supposed to run within a repository clone.
# This script sets up the development environment without installing Agama packages. This script is
# supposed to run within a repository clone.

# Exit on error; unset variables are an error
# Exit on error; unset variables are an error.
set -eu

MYDIR=$(realpath $(dirname $0))
Expand All @@ -21,29 +21,23 @@ else
SUDO=""
fi

# Backend setup

if ! $MYDIR/setup-service.sh; then
echo "Backend setup failed."
echo "Agama service is NOT running."
# Services setup
if ! $MYDIR/setup-services.sh; then
echo "Services setup failed."
echo "Agama services are NOT running."

exit 2
fi;

# Install Frontend dependencies

$SUDO zypper --non-interactive --gpg-auto-import-keys install \
make git 'npm>=18' cockpit

# Web Frontend
# Web setup
if ! $MYDIR/setup-web.sh; then
echo "Web client setup failed."
echo "Agama web client is NOT running."

$SUDO systemctl start cockpit

# set up the web UI
cd web; make devel-install; cd -
$SUDO ln -snf `pwd`/web/dist /usr/share/cockpit/agama
exit 3
fi;

# Start the installer
# Start the installer.
echo
echo "D-Bus will start the services, see journalctl for their logs."
echo "To start the services manually, logging to the terminal:"
Expand Down

0 comments on commit b0ab5a6

Please sign in to comment.