Skip to content

Commit ddcc911

Browse files
move install script into ./scripts ; update Instructions
1 parent 2794a06 commit ddcc911

4 files changed

Lines changed: 57 additions & 43 deletions

File tree

INSTALL/INSTALL.ubuntu2404.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Installation on Ubuntu 24.04
66
Install some utilities, database, webserver
77
```bash
88
sudo apt update
9-
sudo apt-get install -y curl jq mariadb-client mariadb-server apache2
9+
sudo apt-get install -y zip unzip git gettext curl jq mariadb-client mariadb-server apache2
1010
```
1111

1212
Install PHP and its dependencies (the default php version in Ubuntu 24.04 is php8.3):
@@ -16,7 +16,7 @@ sudo apt-get install -y php php-cli php-common php-mysql php-zip php-gd php-mbst
1616

1717
# 2. Monarc files
1818

19-
Run the [get_and_unpack_the_latest_release.sh](./get_and_unpack_the_latest_release.sh) script with `sudo`
19+
Run the [install_latest_fo_release.sh](../scripts/install_latest_fo_release.sh) script with `sudo`
2020
to download the latest Monarc release and unpack it into `/var/lib/monarc/`.
2121

2222
> The script is built to be used in the CI/CD pipelines and will fail with a clear error if the release is not reachable or the deploy directory already exits.
@@ -169,11 +169,9 @@ Configure the database connection (use the secured password set on the DB user c
169169
## 4.5 Migrate the MONARC DB
170170

171171
```bash
172-
php ./vendor/robmorgan/phinx/bin/phinx migrate -c module/Monarc/FrontOffice/migrations/phinx.php
173-
php ./vendor/robmorgan/phinx/bin/phinx migrate -c module/Monarc/Core/migrations/phinx.php
172+
bash ./scripts/upgrade-db.sh
174173
```
175174

176-
177175
## 4.6 Create initial user
178176

179177
```bash

INSTALL/UPDATE.ubuntu.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ curl -sL $MONARCFO_RELEASE_URL -o /var/lib/monarc/releases/`basename $MONARCFO_R
1919
mkdir /var/lib/monarc/releases/`basename $MONARCFO_RELEASE_URL | sed 's/.tar.gz//'`
2020
# Unarchive the release:
2121
tar -xzf /var/lib/monarc/releases/`basename $MONARCFO_RELEASE_URL` -C /var/lib/monarc/releases/`basename $MONARCFO_RELEASE_URL | sed 's/.tar.gz//'`
22+
# Copy existing configuration to the new release.
23+
cp "$PATH_TO_MONARC/config/autoload/local.php" \
24+
"/var/lib/monarc/releases/`basename $MONARCFO_RELEASE_URL | sed 's/.tar.gz//'`/config/autoload/local.php"
2225
# Update the release symlink:
2326
ln -sfn /var/lib/monarc/releases/`basename $MONARCFO_RELEASE_URL | sed 's/.tar.gz//'` $PATH_TO_MONARC
2427
# Migrate the DB:

INSTALL/get_and_unpack_the_latest_release.sh

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
BASEDIR="/var/lib/monarc"
5+
RELEASES="$BASEDIR/releases"
6+
APP_LINK="$BASEDIR/fo"
7+
DATA_DIR="$BASEDIR/fo-data"
8+
9+
function error() { echo "Error: $1" > /dev/stderr; exit 1; }
10+
11+
# ensure no existing release is present
12+
if [ -f "$APP_LINK/config/autoload/local.php" ]; then
13+
echo "Existing Monarc installation found! Run the UPDATE script instead:";
14+
echo " https://github.com/monarc-project/MonarcAppFO/blob/master/INSTALL/UPDATE.ubuntu.md";
15+
error "Aborting installation.";
16+
fi
17+
18+
# Ensure base directories exist
19+
mkdir -p "$RELEASES" "$DATA_DIR"/{cache,DoctrineORMModule/Proxy,LazyServices/Proxy,import/files}
20+
21+
# Get latest version
22+
VERSION=$(curl -s https://api.github.com/repos/monarc-project/MonarcAppFO/releases/latest | jq -r '.tag_name')
23+
if [ -z "$VERSION" ] || [ "$VERSION" = "null" ]; then
24+
error "Failed to resolve app release version"
25+
fi
26+
RELEASE_NAME="MonarcAppFO-${VERSION}"
27+
ARCHIVE_URL="https://github.com/monarc-project/MonarcAppFO/releases/download/${VERSION}/${RELEASE_NAME}.tar.gz"
28+
29+
# Extraction target
30+
TARGET_DIR="$RELEASES/$RELEASE_NAME"
31+
test -d "$TARGET_DIR" && error "$TARGET_DIR already exists!"
32+
mkdir -p "$TARGET_DIR"
33+
34+
echo "Downloading the latest Monarc version $VERSION"
35+
# --strip-components=1 prevents the "folder inside a folder" issue
36+
curl -L "$ARCHIVE_URL" | tar -xzf - -C "$TARGET_DIR" --strip-components=1
37+
38+
# if data folder exist in release - remove it to allow symlink
39+
rm -rf "$TARGET_DIR/data"
40+
# Link data folder into release folder
41+
ln -sfn "$DATA_DIR" "$TARGET_DIR/data"
42+
43+
# Link the release into the app folder
44+
ln -sfn "$TARGET_DIR" "$APP_LINK"
45+
46+
# change owner
47+
chown -R www-data:www-data /var/lib/monarc
48+
49+
echo "Monarc version $VERSION files was installed successfully!"
50+
echo "No database or web-server configuration changes were made."
51+
echo "Follow the installation instruction for the next steps."

0 commit comments

Comments
 (0)