mirror of
https://codeberg.org/vegvisir/install.git
synced 2025-09-14 00:33:41 +02:00
Compare commits
No commits in common. "f0c03d6b1534cce6575f2366ebe6ee886ec9734f" and "0f23cf1e167d3b2232fb44d33518331d27483e6a" have entirely different histories.
f0c03d6b15
...
0f23cf1e16
2 changed files with 30 additions and 115 deletions
41
README.md
41
README.md
|
@ -1,40 +1,13 @@
|
|||
# Vegvisir installer
|
||||
Run this script from a git repository to automatically install and configure Vegvisir as a git submodule to your project.
|
||||
This script will automatically install and configure Vegvisir from in a fresh git repository.
|
||||
|
||||
> [!IMPORTANT]
|
||||
> The script will only run in environments with Bash and `coreutils` installed (for now).
|
||||
## Important
|
||||
The script will only run on Linux environments with `coreutils` installed (for now).
|
||||
|
||||
# Get started
|
||||
1. Create a git repository for your project.
|
||||
2. Run this command from the root directory of your local repository.
|
||||
1. Create a repository for your website
|
||||
2. Run this command from the root directory of your local repository
|
||||
|
||||
```sh
|
||||
curl -fsSL https://codeberg.org/vegvisir/install/raw/branch/master/install.sh | bash
|
||||
```
|
||||
|
||||
# Arguments
|
||||
You can pass optional named arguments to this script for headless installation of Vegvisir.
|
||||
|
||||
### `--install` - Don't install, only configure Vegvisir
|
||||
```sh
|
||||
./install.sh --install=n
|
||||
```
|
||||
Pass `--install=n` to prevent download and installation of the Vegvisir git submodule. Use this option if you're version controlling Vegvisir from your project repository.
|
||||
|
||||
### `--dir` - Installation directory
|
||||
```sh
|
||||
./install.sh --dir="/path/to/project"
|
||||
```
|
||||
Pass a `--dir` argument with a value of a directory Vegvisir should consider its [`root_path`](https://vegvisir.vlw.se/docs/Reference/Env#root_path).
|
||||
|
||||
### `--overwrite` - Overwrite configuration files
|
||||
```sh
|
||||
./install.sh --overwrite=y
|
||||
```
|
||||
Pass `--overwrite=y` to replace existing Vegvisir configuration files.
|
||||
|
||||
### `--example` - Generate example website
|
||||
```sh
|
||||
./install.sh --example=n
|
||||
```
|
||||
Pass `--overwrite=n` to disable generation of an example website after installation.
|
||||
curl -fsSL https://href.vlw.se/vegvisir/install | bash
|
||||
```
|
104
install.sh
104
install.sh
|
@ -1,11 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Initialize variables
|
||||
cwd=""
|
||||
dir=""
|
||||
install=""
|
||||
example=""
|
||||
overwrite=""
|
||||
# Get the current working directory
|
||||
cwd=$(pwd)
|
||||
|
||||
echo_err() {
|
||||
echo "!! -> $1"
|
||||
|
@ -37,19 +33,16 @@ check_sys_depend() {
|
|||
|
||||
install_vegvisir() {
|
||||
if ! [ -d ".git" ] ; then
|
||||
echo_err "Installation aborted: '$cwd' is not a git repository"
|
||||
echo_err "Not in a git repository"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Download and install the Vegvisir repository
|
||||
if [[ "$install" != "n" ]]; then
|
||||
if ! [ -d "vegvisir" ] ; then
|
||||
git submodule add https://codeberg.org/vegvisir/vegvisir
|
||||
fi
|
||||
|
||||
# Update submodules
|
||||
git submodule update --init --recursive
|
||||
if ! [ -d "vegvisir" ] ; then
|
||||
git submodule add https://codeberg.org/vegvisir/vegvisir
|
||||
fi
|
||||
|
||||
# Update submodules
|
||||
git submodule update --init --recursive
|
||||
|
||||
# Install dependencies with composer
|
||||
(cd vegvisir && composer install --classmap-authoritative)
|
||||
|
@ -57,14 +50,7 @@ install_vegvisir() {
|
|||
# Bail out if composer didn't create a vendor folder
|
||||
if ! [ -d "vegvisir/vendor" ] ; then
|
||||
echo_err "Something went wrong with the installation."
|
||||
|
||||
# Script was not run with the install flag disabled, this is probably a bug
|
||||
if [[ "$install" != "n" ]]; then
|
||||
exit_report
|
||||
fi
|
||||
|
||||
echo_err "Make sure you have cloned the Vegvisir repository. Or run without '--install=n'."
|
||||
exit 1
|
||||
exit_report
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -75,14 +61,12 @@ configure_vegvisir() {
|
|||
fi
|
||||
|
||||
# A configuration file already exists
|
||||
if [[ -f "vegvisir/.env.ini" ]] ; then
|
||||
if ! [[ -n "$overwrite" ]]; then
|
||||
echo "A Vegvisir configuration file already exists at: ${cwd}/vegvisir/.env.ini"
|
||||
read -p "Do you want to overwrite this file? (y/n): " overwrite </dev/tty
|
||||
fi
|
||||
if [ -f "vegvisir/.env.ini" ] ; then
|
||||
echo "A Vegvisir configuration file already exists at: ${cwd}/vegvisir/.env.ini"
|
||||
read -p "Do you want to overwrite this file? (y/n): " choice </dev/tty
|
||||
|
||||
# Check the user's response
|
||||
if [[ "$overwrite" == "y" || "$overwrite" == "Y" ]] ; then
|
||||
if [[ "$choice" == "y" || "$choice" == "Y" ]] ; then
|
||||
echo "Removing existing Vegvisir configuration and proceeding with the installation in ${cwd}..."
|
||||
rm vegvisir/.env.ini
|
||||
else
|
||||
|
@ -97,6 +81,8 @@ configure_vegvisir() {
|
|||
"root_path = '${cwd}'"
|
||||
"shell_page = 'public/shell'"
|
||||
"public_path = 'public/'"
|
||||
"worker_magic_pathname = '/__vvnavwrkr'"
|
||||
"rfc_4288_url = 'https://raw.githubusercontent.com/apache/httpd/refs/heads/trunk/docs/conf/mime.types'"
|
||||
)
|
||||
|
||||
for line in "${config[@]}" ; do
|
||||
|
@ -166,73 +152,29 @@ generate_example_website() {
|
|||
}
|
||||
|
||||
main() {
|
||||
# Get the current working directory
|
||||
cwd=$(pwd)
|
||||
|
||||
check_sys_depend
|
||||
install_vegvisir
|
||||
configure_vegvisir
|
||||
|
||||
echo "Vegvisir has been sucessfully installed."
|
||||
read -p "Do you want to generate a simple example website to start from? (y/n): " choice </dev/tty
|
||||
|
||||
if [[ "$example" != "n" ]]; then
|
||||
read -p "Do you want to generate a simple example website to start from? (y/n): " choice </dev/tty
|
||||
|
||||
# Check the user's response
|
||||
if [[ "$choice" == "y" || "$choice" == "Y" ]] ; then
|
||||
generate_example_website
|
||||
fi
|
||||
# Check the user's response
|
||||
if [[ "$choice" == "y" || "$choice" == "Y" ]] ; then
|
||||
generate_example_website
|
||||
fi
|
||||
|
||||
echo "Done! Thank you for choosing Vegvisir :)"
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Loop through all arguments
|
||||
for arg in "$@"; do
|
||||
case $arg in
|
||||
--dir=*)
|
||||
dir="${arg#*=}"
|
||||
;;
|
||||
|
||||
--install=*)
|
||||
install="${arg#*=}"
|
||||
;;
|
||||
|
||||
--overwrite=*)
|
||||
overwrite="${arg#*=}"
|
||||
;;
|
||||
|
||||
--example=*)
|
||||
example="${arg#*=}"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo_err "Unknown argument: $arg"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Start execution immediately if an install directory was passed
|
||||
if [ -n "$dir" ]; then
|
||||
if ! [ -d "$dir" ]; then
|
||||
echo_err "Installation aborted: '$dir' is not a directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Move to install directory and run main
|
||||
cd $dir
|
||||
main
|
||||
fi
|
||||
|
||||
# Prompt the user for confirmation
|
||||
echo "You are currently in: $(pwd)"
|
||||
echo "You are currently in: ${cwd}"
|
||||
read -p "Do you want to proceed with the installation in this directory? (y/n): " choice </dev/tty
|
||||
|
||||
# Check the user's response
|
||||
if [[ "$choice" == "y" || "$choice" == "Y" ]] ; then
|
||||
echo "Proceeding with the installation in $(pwd)..."
|
||||
main
|
||||
echo "Proceeding with the installation in ${cwd}..."
|
||||
main
|
||||
else
|
||||
echo "Installation aborted."
|
||||
echo "Installation aborted."
|
||||
fi
|
Loading…
Add table
Reference in a new issue