Compare commits

...

7 Commits

14 changed files with 86 additions and 216 deletions

View File

@ -1 +1,10 @@
Development helper scripts.
Development environment base packages:
* nvm
* lf
* lazygit
## TODO
* add wakatime key when configuring neovim

View File

@ -1,4 +1,9 @@
# local specific options
## export if using local development environment
export domain='test123.home'
export url='http://test123.home'
# set to anything other than the empty string to set up a dev environment
export dev_env='true'

View File

@ -1,3 +1,5 @@
# remote specific options
## export if using local development environment
#export domain='test123.example.com'
#export url='http://test123.example.com'

View File

@ -1,41 +0,0 @@
#!/bin/sh
export domain='test123.home'
export url='http://test123.home'
export ssh='root@test123.home'
# webuser/webgroup not yet implemented
export webuser='ray'
export webgroup='ray'
export db_root_pass='root'
export wp_db_name='wordpress'
export wp_db_user='wordpress'
export wp_db_pass='wordpress'
export wp_path='/var/www/html/wordpress'
export wp_user='admin'
export wp_pass='admin'
# list of themes to install - first one will be activate
export wp_themes="twentytwenty"
export wp_plugins=""
export wp_plugins_active="block-lab"
export wp_plugins_uninstall="hello aksimet"
export php_version=''
# set one of
export mariadb_version=''
export mysql_version=''
# set one of
export apache2_version=''
export nginx_version=''
# LSPHPVERLIST=(54 55 56 70 71 72 73 74)
export litespeed_version='latest'
#set if using litespeed
# https://openlitespeed.org/kb/1-click-install/
# password used to log into litespeed web interface)
export ls_webadmin_pass='admin'
export ls_lsphp_version='73'

View File

@ -1,41 +0,0 @@
#!/bin/sh
export domain='test123.isnet.uk'
export url='http://test123.isnet.uk'
export ssh='root@test123.isnet.uk'
# webuser/webgroup not yet implemented
export webuser=''
export webgroup=''
export db_root_pass='39dn,s9889d89--sdj_UUUY'
export wp_db_name='wordpress'
export wp_db_user='wordpress'
export wp_db_pass='39fhi3nkjdf__dlk8-ddWEs'
export wp_path='/var/www/html/wordpress'
export wp_user='admin'
export wp_pass='f988888--3XSD'
# list of themes to install - first one will be activate
export wp_themes="twentytwenty"
export wp_plugins=""
export wp_plugins_active=""
export wp_plugins_uninstall="hello aksimet"
export php_version=''
# set one of
export mariadb_version=''
export mysql_version=''
# set one of
export apache2_version=''
export nginx_version=''
# LSPHPVERLIST=(54 55 56 70 71 72 73 74)
export litespeed_version='latest'
#set if using litespeed
# https://openlitespeed.org/kb/1-click-install/
# password used to log into litespeed web interface)
export ls_webadmin_pass='x7856----DD'
export ls_lsphp_version='73'

View File

@ -1,3 +0,0 @@
#!/bin/sh

View File

@ -1,17 +0,0 @@
#!/bin/sh
if [ -z "$1" ] ; then
echo "error: must specify configuration file to use"
exit 5
fi
. ./"$1"
ssh -T $src_ssh << EOSSH
ufw allow http && ufw allow https
echo "TODO install apache"
exit 1
EOSSH

View File

@ -1,24 +0,0 @@
#!/bin/sh
if [ -z "$1" ] ; then
echo "error: must specify configuration file to use"
exit 5
fi
. ./"$1"
ssh -T $ssh << EOSSH
apt update || exit 5
apt upgrade -y || exit 10
apt install -y tmux ufw curl || exit 15
sed -i '/PubkeyAuthentication/c\PubkeyAuthentication yes' /etc/ssh/sshd_config
sed -i '/PasswordAuthentication/c\PasswordAuthentication no' /etc/ssh/sshd_config
sed -i '/PermitRootLogin/c\PermitRootLogin prohibit-password' /etc/ssh/sshd_config
systemctl restart sshd
ufw allow ssh || exit 20
yes | ufw enable
EOSSH

View File

@ -1,3 +0,0 @@
#!/bin/sh

View File

@ -1,3 +0,0 @@
#!/bin/sh

View File

@ -1,3 +0,0 @@
#!/bin/sh

View File

@ -1,80 +0,0 @@
#!/bin/sh
if [ -z "$1" ] ; then
echo "error: must specify configuration file to use"
exit 5
fi
. ./"$1"
ssh -T $ssh << EOSSH
if [ -n "$php_version" ] ; then
echo "TODO - install specific PHP version"
exit 1
elif ! php ; then
apt install -y php-fpm php-bcmath php-curl php-gd php-imagick php-mbstring \
php-mysql php-soap php-xml php-zip
fi
php_config_file=$(php --ini | grep Loaded | awk '{ print $4 }')
sed -i '/memory_limit/c\memory_limit = 256M' "$php_config_file"
sed -i '/upload_max_filesize/c\upload_max_filesize = 64M' "$php_config_file"
sed -i '/post_max_size/c\post_max_size = 64M' "$php_config_file"
sed -i '/max_execution_time/c\max_execution_time = 300M' "$php_config_file"
sed -i '/max_input_time/c\max_input_time = 1000' "$php_config_file"
# install wp-cli first
if [ ! -f /usr/local/bin/wp ] ; then
wget -nv -O /usr/local/bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar \
&& chmod +x /usr/local/bin/wp
fi
if wp core is-installed --quiet --path="$wp_path" --allow-root ; then
echo "WordPress already installed"
else
echo "TODO - install WordPress"
fi
if [ -n "$wp_themes" ] ; then
printf "\nInstalling themes ..."
option='--activate'
for theme in $wp_themes ; do
echo " installing $theme ..."
wp theme install $theme "$option" --path="$wp_path" --allow-root
option=''
done
fi
if [ -n "$wp_plugins" ] ; then
printf "\nInstalling plugins ..."
for plugin in $wp_plugins ; do
echo " installing $plugin ..."
wp plugin install $plugin --path="$wp_path" --allow-root
done
fi
if [ -n "$wp_plugins_active" ] ; then
printf "\nInstalling plugins to activate ..."
for plugin in $wp_plugins_active ; do
echo " installing $plugin ..."
wp plugin install $plugin --activate --path="$wp_path" --allow-root
done
fi
if [ -n "$wp_plugins_active" ] ; then
printf "\nUninstalling plugins ..."
for plugin in $wp_plugins_uninstall ; do
echo " installing $plugin ..."
wp plugin deactivate $plugin --path="$wp_path" --allow-root
wp plugin uninstall $plugin --path="$wp_path" --allow-root
done
fi
# TODO determine web user programatically
ownergroup='www-data:www-data'
if [ -n "$litespeed_version" ] ; then
ownergroup='nobody:nogroup'
fi
chown -R "$ownergroup" "$wp_path"
EOSSH

View File

@ -0,0 +1,61 @@
#!/bin/sh
_home_dir="/home/$user"
ssh -T $ssh << EOSSH
echo "Installing packages .."
apt-get -y install curl gnupg2 ninja-build gettext libtool libtool-bin autoconf automake cmake g++ pkg-config unzip python-pip python3-pip fzf
echo "Installing lazygit .."
curl -fsSL https://github.com/jesseduffield/lazygit/releases/download/v0.22.1/lazygit_0.22.1_Linux_x86_64.tar.gz --output /tmp/lazygit.tar.gz
tar xf /tmp/lazygit.tar.gz -C /usr/local/bin/
rm /tmp/lazygit.tar.gz
echo "Installing lf ..."
curl -fsSL https://github.com/gokcehan/lf/releases/download/r16/lf-linux-amd64.tar.gz --output /tmp/lf.tar.gz
tar xf /tmp/lf.tar.gz -C /usr/local/bin/
rm /tmp/lf.tar.gz
echo "Installing neovim ..."
git clone https://github.com/neovim/neovim /tmp/neovim
cd /tmp/neovim
make CMAKE_BUILD_TYPE=Release
make install
su "$user"
echo "Installing nvm ..."
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
echo 'export NVM_DIR="\$HOME/.nvm"' >> "$_home_dir/.profile"
echo '[ -s "\$NVM_DIR/nvm.sh" ] && \. "\$NVM_DIR/nvm.sh"' >> "$_home_dir/.profile"
exit
su --login "$user"
. ./.profile
nvm install --lts --latest-npm
exit
su --login "$user"
. ./.profile
echo "Configuring neovim ..."
npm install -g neovim
python2 -m pip install --user --upgrade pynvim
python3 -m pip install --user --upgrade pynvim
python3 -m pip install --user --upgrade neovim-remote
git clone https://git.rayelliott.dev/dots/nvim.git $_home_dir/.config/nvim
curl -fLo $_home_dir/.config/nvim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
nvim --headless +PlugInstall +qall
# TODO wakatime api key
echo "Configuring lf .."
lf config
if [ -e "$_home_dir/.config/lf" ] ; then
mv "$_home_dir/.config/lf" "$_home_dir/.config/lf-original-$(date +%s)"
fi
git clone https://git.rayelliott.dev/dots/lf.git "$_home_dir/.config/lf"
EOSSH

View File

@ -5,6 +5,14 @@ _home_dir="/home/$user"
echo "Adding user: $user"
ssh -T $ssh << EOSSH
if [ -f /etc/locale.gen ] && command -v locale-gen ; then
echo 'en_GB.UTF-8 UTF-8' > /etc/locale.gen
locale-gen
echo 'LANG="en_GB.UTF-8"' > /etc/default/locale
else
echo 'Warning: cannot set locale'
fi
echo "Installing required packages .."
export DEBIAN_FRONTEND=noninteractive
apt-get --assume-yes install sudo git tmux zsh curl