dotfiles/.local/bin/vlw_install_programs

118 lines
No EOL
3 KiB
Bash
Executable file

#!/bin/bash
install_packages() {
local PACKAGES=(
"jq"
"git"
"curl"
)
# Create a string with the package names separated by spaces
local package_list="${PACKAGES[*]}"
sudo apt update
sudo apt install -y $package_list
}
install_mariadb() {
local PACKAGES=(
"mysql-client"
"mariadb-server"
)
sudo apt install $PACKAGES[*]
# Create a database user for the webserver
sudo mysql -u root -e "CREATE USER 'www-data'@'localhost' IDENTIFIED WITH unix_socket; GRANT ALL PRIVILEGES ON *.* TO 'www-data'@'localhost' WITH GRANT OPTION; FLUSH PRIVILEGES;"
}
install_webserver() {
local WWW_PATH="/var/www"
local PATH_NGINX="/etc/nginx"
local PACKAGES=(
"nginx"
"composer"
)
sudo apt install $PACKAGES[*]
sudo mkdir $WWW_PATH/fw
sudo mkdir $WWW_PATH/tools
sudo mkdir $WWW_PATH/sites
sudo rm -r $WWW_PATH/default
sudo rm $PATH_NGINX/sites-enabled/default
# Download default configs
sudo curl -o $PATH_NGINX/snippets https://git.vlw.se/config/nginx/raw/branch/master/snippets/ssl.conf
sudo curl -o $PATH_NGINX/sites-available https://git.vlw.se/config/nginx/raw/branch/master/dev/sites-available/80.conf
sudo curl -o $PATH_NGINX/sites-available https://git.vlw.se/config/nginx/raw/branch/master/dev/sites-available/443.conf
# Download and install Vegvisir
cd $WWW_PATH/fw
git clone git@codeberg.org:vegvisir/vegvisir
cd $WWW_PATH/fw/vegvisir
composer install
cp -p .env.example.ini .env.ini
# Download and install Reflect
cd $WWW_PATH/fw
git clone git@codeberg.org:reflect/reflect
cd $WWW_PATH/fw/reflect
composer install
cp -p .env.example.ini .env.ini
sudo chown :www-data -R $WWW_PATH
}
install_php_fpm() {
local PHP_VERSION="8.4"
local PHP_INI_PATH="/etc/php/$PHP_VERSION/fpm/php.ini"
local PACKAGES=(
"lsb-release"
"ca-certificates"
"php$PHP_VERSION-fpm"
"php$PHP_VERSION-mysql"
"php$PHP_VERSION-xdebug"
"php$PHP_VERSION-mbstring"
)
# https://packages.sury.org/php/README.txt
sudo curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb
sudo dpkg -i /tmp/debsuryorg-archive-keyring.deb
sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/debsuryorg-archive-keyring.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
# Install packages
sudo apt update
sudo apt install $PACKAGES[*]
# Make a backup of the php.ini file
sudo cp -p "$PHP_INI_PATH" "$PHP_INI_PATH~"
# Use sed to replace the zend_extension line
sudo sed -i 's/^zend_extension=.*/zend_extension=xdebug/' "$PHP_INI_PATH"
sudo systemctl restart php$PHP_VERSION-fpm
}
install_code_server() {
local EXTENSIONS_FILE="$HOME/.local/share/code-server/User/extensions.json"
# https://coder.com/docs/code-server/install
curl -fsSL https://code-server.dev/install.sh | sh
# Install extensions
jq -r '.[]' $EXTENSIONS_FILE | while IFS= read -r extension; do
code-server --install-extension $extension
done
}
install_packages
install_php_fpm
install_webserver
#install_code_server