Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH][DOC]: Add a script for installation and upgrade options for specific Cypht versions #93

Closed

Conversation

Baraka24
Copy link
Member

@Baraka24 Baraka24 commented Dec 4, 2024

Related Issue

Summary

This pull request introduces an enhanced installation script for Cypht that supports both installation of specific versions and the ability to upgrade from one version to another. The script automates the process of downloading the selected version, unpacking the archive, running the necessary Composer install steps, and configuring the installation with the appropriate settings. Additionally, it now handles the safe movement of both regular and hidden files, ensuring that all required files, including configuration files like .env.example and .gitignore, are correctly copied to the target installation directory.

Changes:

  • Prerequisite Check: Added a check for Composer to ensure it's installed before proceeding with the installation.
  • Install Cypht:
    • The script downloads the selected Cypht version from GitHub using the version tag, unpacks it, and runs composer install.
    • Configuration files are created based on the version of Cypht, with hm3.ini for version 1.4.x and .env for other versions.
    • Moves all files, including hidden ones, to the target directory.
  • Upgrade Cypht:
    • The script now supports upgrading from one Cypht version to another. It first checks if the current version exists, backs it up, and then proceeds with the installation of the new version.
    • A backup of the current installation is created in a temporary directory to ensure data safety during upgrades.

Why this change?

The goal of this change is to provide a more flexible and automated installation and upgrade process for Cypht, addressing both new installations of specific versions and upgrades from older versions. This enhances the usability and maintainability of Cypht installations, ensuring that all necessary files are correctly handled during installation, including hidden files that are essential for the proper functioning of the application.

Testing:

  • Verified that the script correctly installs the desired version by downloading the ZIP archive from GitHub.
  • Tested both the installation and upgrade processes to ensure that files (including hidden ones) are correctly moved to the destination directory.
  • Verified that configuration files are generated correctly based on the Cypht version (i.e., .env or hm3.ini).

Additional Notes:

  • The script now uses wget to download the ZIP file of the selected version and unzip to unpack it.
  • The composer install step is executed to ensure all dependencies are correctly installed for the selected version.
  • This PR allows for greater flexibility when installing and upgrading Cypht, particularly in production environments where specific versions may need to be installed.

@Baraka24 Baraka24 assigned josaphatim and unassigned josaphatim Dec 4, 2024
@Baraka24 Baraka24 requested a review from josaphatim December 4, 2024 21:03
install.html Outdated
@@ -93,12 +82,12 @@ <h2>Install Cypht master</h2>
<hr>
<h2>1. Manual installation</h2>
<h2>Requirements</h2>
<p>Cypht master requires at least PHP 8.1, <a href="https://getcomposer.org/">Composer 2</a>, and at minimum the
<p>Cypht 1.4.x requires PHP 5.6 or 7.0 or 7.1 or 7.2 or 7.3 or 7.4 (for PHP 8.1+, please use Cypht 2.1+), <a href="https://getcomposer.org/">Composer 2</a>, and at minimum the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just put a range here instead of listing all versions ? Also isn't better to add the link when you talk about Cypht 2.1+ ?

install.html Outdated

if [ "$choice" -eq 1 ]; then
# Install specific version
read -p "Enter the version to install (e.g., 2.1.0, 2.2.0, etc.): " version
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please provide a default version? And can you also list the tag versions as options so the user doesn't have to fumble around? That way if they enter an invalid option it will be handled properly. https://api.github.com/repos/cypht-org/cypht/tags will help you get the list of tags.

install.html Outdated
sudo test -r $DESTINATION -a -x $DESTINATION
if [ $? -ne 0 ]; then
sudo mkdir $DESTINATION
# Base directory for Cypht installations
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about windows users. Can we handle this for now ?

Also I have an idea if @kroky agrees. We can put the code below in a file and put a download link here then one can just execute it. All static variables here that the user can change may be options.

install.html Outdated
# Fix permissions and ownership
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
sudo chown -R root:root .
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is there is not group root ? on my case on macOS I don't have that. Perhaps It can be better to asked this to the user.

install.html Outdated
echo "Cypht $version installed successfully to $destination"
}

# Function to upgrade Cypht from one version to another
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will be difficult to handle. Cypht 1.x uses ini files, some in module folders but Cypht 2.x uses .env file and config folder for configuration. It will be a bit complicated to rewrite the contents of the different .ini files to the .env. Some variables where renamed in the new .env.

In my opinion we can perhaps upgrade to the same version. For example from v1.3.0 to v1.4.4.

Also what if one wants to test multiple versions ?

install.html Outdated
composer install

# Handle configuration file creation
if [[ "$version" =~ ^1\.4\.[0-9]+$ ]]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change the regex here as there are other tags for Cypht version 1 that don't start with 1.4 ?

install.html Outdated
}

# Function to upgrade Cypht from one version to another
upgrade_cypht() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function doesn't work as expected. Can you review it please ?

install.html Outdated

<pre>sudo mkdir /var/lib/hm3
<pre>
sudo mkdir /var/lib/hm3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we replace this with something like sudo mkdir -p /var/lib/hm3/{attachments,users,app_data} ?

install.html Outdated
<h4>8. Other INI files</h4>
<p>Some Cypht modules require additional ini files to be configured. These should NOT be inside the web-server
document root. Cypht will look for them in the location defined by "app_data_dir" in the hm3.ini file. A
sample
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check formatting here please ?

@Baraka24 Baraka24 mentioned this pull request Dec 23, 2024
11 tasks
@Denperidge Denperidge self-assigned this Dec 28, 2024
@Denperidge
Copy link
Contributor

Hi @Baraka24! I can adapt the contents to the new site structure, but would it perhaps be easier for you to first take care of the comments posted above, and then afterwards me moving it to the correct spot?

I can also move it first if you prefer, but due to the removal of the different install-1x & install-2x, it will no longer require the fancy tricks used in the current SSG adaptation.

@Baraka24 Baraka24 closed this Dec 31, 2024
@Baraka24 Baraka24 force-pushed the installation-and-upgrade-script branch from 2e5b787 to 157a8ef Compare December 31, 2024 13:27
@Baraka24
Copy link
Member Author

Hi @Baraka24! I can adapt .......?

I can also move it first if you prefer, but due to the removal of the different install-1x & install-2x, it will no longer require the fancy tricks used in the current SSG adaptation.

@Denperidge, here’s what I need: please update the layouts/partials/install.html.twig and both the install-1x and install-2x files so we only have the install file remaining. I'll adapt my changes according to the reviews here. This PR was closed because I rebased it, and compared to master, there are no changes. Once this is done, I will bring back the suggested changes in the new install file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants