mirror of
https://codeberg.org/vlw/dotfiles.git
synced 2026-01-12 13:46:01 +01:00
Compare commits
3 commits
612fc10935
...
0655fbf942
| Author | SHA1 | Date | |
|---|---|---|---|
| 0655fbf942 | |||
| ae3b0ec4e8 | |||
| 39f4227c06 |
4 changed files with 168 additions and 6 deletions
|
|
@ -162,18 +162,33 @@ gitf () {
|
||||||
gitf
|
gitf
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# Checkout [and create] a git branch (defaults to "master")
|
# Checkout a git branch (defaults to "master")
|
||||||
"b")
|
"b")
|
||||||
local branch="${2:-master}"
|
local branch="${2:-master}"
|
||||||
|
|
||||||
if git show-ref --verify --quiet refs/heads/"$branch"; then
|
if ! git show-ref --verify --quiet refs/heads/"$branch"; then
|
||||||
|
gitf
|
||||||
|
echo ""
|
||||||
|
echo -e "\e[0;91mNo such branch '$branch'\e[0m"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
git checkout $branch
|
git checkout $branch
|
||||||
gitf
|
gitf
|
||||||
|
;;
|
||||||
|
|
||||||
|
# Checkout [and create] a git branch (defaults to "master")
|
||||||
|
"cb")
|
||||||
|
local branch="${2:-master}"
|
||||||
|
|
||||||
|
# Checkout existing branch
|
||||||
|
if git show-ref --verify --quiet refs/heads/"$branch"; then
|
||||||
|
gitf b $branch
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git checkout -b $branch
|
git checkout -b $branch
|
||||||
gitf
|
gitf b $branch
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# Pull current branch from a remote (defaults to "origin"). "d" for download.
|
# Pull current branch from a remote (defaults to "origin"). "d" for download.
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,9 @@
|
||||||
|
|
||||||
cp -rp . $HOME
|
cp -rp . $HOME
|
||||||
cd ..
|
cd ..
|
||||||
rm -r dotfiles
|
|
||||||
|
source .bash_profile
|
||||||
|
source .bash_aliases
|
||||||
|
|
||||||
|
echo "dotfiles copied to '$HOME'. Removing directory: '$(pwd)'"
|
||||||
|
sudo rm -rf dotfiles
|
||||||
|
|
|
||||||
138
.local/bin/scripts/install_programs.sh
Normal file
138
.local/bin/scripts/install_programs.sh
Normal file
|
|
@ -0,0 +1,138 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
install_packages() {
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install -y jq git curl tmux
|
||||||
|
}
|
||||||
|
|
||||||
|
install_mariadb() {
|
||||||
|
sudo apt install -y default-mysql-client mariadb-server
|
||||||
|
|
||||||
|
# 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;"
|
||||||
|
sudo mysql -u root -e "CREATE USER '$(whoami)'@'localhost' IDENTIFIED WITH unix_socket; GRANT ALL PRIVILEGES ON *.* TO '$(whoami)'@'localhost' WITH GRANT OPTION; FLUSH PRIVILEGES;"
|
||||||
|
}
|
||||||
|
|
||||||
|
install_vegvisir() {
|
||||||
|
local PATH_TMP="/tmp/tmp-vegvisir"
|
||||||
|
|
||||||
|
# Create a git directory where we will install Vegvisir temporarily
|
||||||
|
sudo rm -rf $PATH_TMP
|
||||||
|
mkdir $PATH_TMP
|
||||||
|
cd $PATH_TMP
|
||||||
|
git init
|
||||||
|
|
||||||
|
# Download and install Vegvisir
|
||||||
|
cd $PATH_FW
|
||||||
|
curl -fsSL https://codeberg.org/vegvisir/install/raw/branch/master/nginx/install.sh | bash -s -- --install=y --overwrite=y --example=n --dir="$PATH_TMP"
|
||||||
|
|
||||||
|
# Move the Vegvisir installation to the frameworks folder
|
||||||
|
sudo rm -rf /var/www/fw/vegvisir
|
||||||
|
sudo mv $PATH_TMP/vegvisir /var/www/fw/vegvisir
|
||||||
|
sudo rm -rf $PATH_TMP
|
||||||
|
}
|
||||||
|
|
||||||
|
install_reflect() {
|
||||||
|
local PATH_TMP="/tmp/tmp-reflect"
|
||||||
|
|
||||||
|
# Create a git directory where we will install Reflect temporarily
|
||||||
|
sudo rm -rf $PATH_TMP
|
||||||
|
mkdir $PATH_TMP
|
||||||
|
cd $PATH_TMP
|
||||||
|
git init
|
||||||
|
|
||||||
|
# Download and install Reflect
|
||||||
|
cd $PATH_FW
|
||||||
|
curl -fsSL https://codeberg.org/reflect/install/raw/branch/master/nginx/install.sh | bash -s -- --install=y --overwrite=y --seed=n --dir="$PATH_TMP" --endpoints="api" --host="localhost" --user="www-data" --password="null" --db="reflect"
|
||||||
|
|
||||||
|
# Move the Reflect installation to the frameworks folder
|
||||||
|
sudo rm -rf /var/www/fw/reflect
|
||||||
|
sudo mv $PATH_TMP/reflect /var/www/fw
|
||||||
|
sudo rm -rf $PATH_TMP
|
||||||
|
}
|
||||||
|
|
||||||
|
install_webserver() {
|
||||||
|
local WWW_PATH="/var/www"
|
||||||
|
local PATH_NGINX="/etc/nginx"
|
||||||
|
|
||||||
|
sudo apt install -y nginx composer
|
||||||
|
|
||||||
|
sudo mkdir $WWW_PATH/fw
|
||||||
|
sudo mkdir $WWW_PATH/libs
|
||||||
|
sudo mkdir $WWW_PATH/tools
|
||||||
|
sudo mkdir $WWW_PATH/sites
|
||||||
|
|
||||||
|
sudo rm -r $WWW_PATH/html
|
||||||
|
sudo rm $PATH_NGINX/sites-enabled/default
|
||||||
|
|
||||||
|
# Download default configs
|
||||||
|
sudo curl -o $PATH_NGINX/snippets/vlw.se-ssl.conf https://git.vlw.se/config/dev/raw/branch/master/nginx/snippets/vlw.se-ssl.conf
|
||||||
|
sudo curl -o $PATH_NGINX/snippets/fastcgi-php.conf https://git.vlw.se/config/dev/raw/branch/master/nginx/snippets/fastcgi-php.conf
|
||||||
|
sudo curl -o $PATH_NGINX/sites-available/8001.conf https://git.vlw.se/config/dev/raw/branch/master/nginx/sites-available/8001.conf
|
||||||
|
sudo curl -o $PATH_NGINX/sites-available/8002.conf https://git.vlw.se/config/dev/raw/branch/master/nginx/sites-available/8002.conf
|
||||||
|
sudo curl -o $PATH_NGINX/sites-available/8003.conf https://git.vlw.se/config/dev/raw/branch/master/nginx/sites-available/8003.conf
|
||||||
|
|
||||||
|
sudo rm /etc/nginx/sites-enabled/8001.conf
|
||||||
|
sudo rm /etc/nginx/sites-enabled/8002.conf
|
||||||
|
sudo rm /etc/nginx/sites-enabled/8003.conf
|
||||||
|
sudo ln -s /etc/nginx/sites-available/8001.conf /etc/nginx/sites-enabled
|
||||||
|
sudo ln -s /etc/nginx/sites-available/8002.conf /etc/nginx/sites-enabled
|
||||||
|
sudo ln -s /etc/nginx/sites-available/8003.conf /etc/nginx/sites-enabled
|
||||||
|
|
||||||
|
sudo chown $(whoami):www-data -R $WWW_PATH
|
||||||
|
|
||||||
|
sudo systemctl restart nginx
|
||||||
|
}
|
||||||
|
|
||||||
|
install_pma() {
|
||||||
|
local VERSION="5.2.3"
|
||||||
|
local PATH_TOOLS="/var/www/tools"
|
||||||
|
|
||||||
|
curl -L https://files.phpmyadmin.net/phpMyAdmin/$VERSION/phpMyAdmin-$VERSION-english.tar.gz | tar -xz -C /tmp
|
||||||
|
sudo mv /tmp/phpMyAdmin-$VERSION-english $PATH_TOOLS/pma
|
||||||
|
sudo chown :www-data -R $PATH_TOOLS/pma
|
||||||
|
|
||||||
|
sudo curl -o $PATH_TOOLS/pma/config.inc.php https://git.vlw.se/config/dev/raw/branch/master/pma/config.inc.php
|
||||||
|
}
|
||||||
|
|
||||||
|
install_php_fpm() {
|
||||||
|
local PHP_VERSION="8.4"
|
||||||
|
local PHP_INI_PATH="/etc/php/$PHP_VERSION/fpm/php.ini"
|
||||||
|
|
||||||
|
# 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 -y install lsb-release ca-certificates php$PHP_VERSION-fpm php$PHP_VERSION-mysql php$PHP_VERSION-xdebug php$PHP_VERSION-mbstring php$PHP_VERSION-intl
|
||||||
|
|
||||||
|
# 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_vegvisir
|
||||||
|
install_reflect
|
||||||
|
install_pma
|
||||||
|
install_mariadb
|
||||||
|
install_code_server
|
||||||
6
Makefile
6
Makefile
|
|
@ -1,4 +1,4 @@
|
||||||
install: dotfiles git-hooks
|
install: dotfiles git-hooks programs
|
||||||
|
|
||||||
# Install dotfiles in users home directory
|
# Install dotfiles in users home directory
|
||||||
dotfiles:
|
dotfiles:
|
||||||
|
|
@ -11,3 +11,7 @@ git-hooks:
|
||||||
# Export code-server extensions to config directory
|
# Export code-server extensions to config directory
|
||||||
code-extensions:
|
code-extensions:
|
||||||
~/.local/bin/scripts/code_server_export_extensions.sh
|
~/.local/bin/scripts/code_server_export_extensions.sh
|
||||||
|
|
||||||
|
# Install dev programs and configuration files
|
||||||
|
programs:
|
||||||
|
~/.local/bin/scripts/install_programs.sh
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue