Compare commits

...

29 Commits

Author SHA1 Message Date
Ray Elliott 9e0fa13fce install dev env abse script 2020-09-04 19:09:45 +01:00
Ray Elliott 81a2f46cb9 create option to set up development environment base 2020-09-04 18:51:37 +01:00
Ray Elliott ce9fc451cd set locale within install-user script 2020-09-04 18:50:00 +01:00
Ray Elliott b179e15f47 add development environment base script 2020-09-04 17:25:34 +01:00
Ray Elliott 1d609af550 update readme 2020-09-04 17:24:57 +01:00
Ray Elliott 109c0322b6 add explanatory comments 2020-09-04 15:27:22 +01:00
Ray Elliott 4f9667a4e2 rename config/remote/local to config/remote/remote 2020-09-04 15:26:02 +01:00
Ray Elliott db34ac007a remove un-needed files 2020-09-04 15:25:22 +01:00
Ray Elliott 2e8fb2edb9 rename install directories 2020-09-04 15:04:28 +01:00
Ray Elliott 1e5928f613 restructure file layout 2020-09-04 14:49:07 +01:00
Ray Elliott 60bb9d17bc uncomment sample config statements 2020-09-04 14:30:53 +01:00
Ray Elliott 9bfa6f13df move old files to own dierctory 2020-09-04 14:28:44 +01:00
Ray Elliott 8d56a70b16 install wordpress 2020-09-04 14:25:23 +01:00
Ray Elliott 09643a7954 update .gitignor 2020-09-04 14:23:43 +01:00
Ray Elliott 7c0481a960 various fixes 2020-09-04 14:23:11 +01:00
Ray Elliott 8d9df59d11 remove .com from wordpress url, reove allow-root optoins 2020-09-04 13:34:57 +01:00
Ray Elliott 43b8f400eb add wordpress install scripts 2020-09-03 23:06:42 +01:00
Ray Elliott a68f71337b rename wp config files to wordpress 2020-09-03 20:42:01 +01:00
Ray Elliott f80d9ad08b update install modules 2020-09-03 20:40:25 +01:00
Ray Elliott 021d36b131 configure apache2 to use specified user 2020-09-03 20:35:29 +01:00
Ray Elliott 8bea5f2250 add apache2 install script 2020-09-03 20:20:55 +01:00
Ray Elliott abeb23e90b add database install scripts 2020-09-03 20:09:59 +01:00
Ray Elliott 86f56d6d73 add php install script 2020-09-03 19:00:38 +01:00
Ray Elliott 34a29a0a4e add install base script 2020-09-03 18:07:38 +01:00
Ray Elliott de93d3b6ec add user install script 2020-09-03 17:56:14 +01:00
Ray Elliott bd9c597d76 update and upgrade distibution 2020-09-03 14:46:19 +01:00
Ray Elliott d56f9d16f1 modularise configuration files 2020-09-03 12:46:30 +01:00
Ray Elliott edec4803b0 install wordpress 2020-06-25 13:00:38 +01:00
Ray Elliott 5a41d6bd71 modularise server installation 2020-06-25 11:27:14 +01:00
46 changed files with 628 additions and 241 deletions

2
.gitignore vendored
View File

@ -1,2 +0,0 @@
config
config-urls

View File

@ -1,12 +1,10 @@
All scripts require an argument to specify 'local' or 'remote'.
If none given script will exit. Development environment base packages:
Using 'local' will: * nvm
set the source server URL to `$local_url`. * lf
set the destination server URL to `$remote_url`. * lazygit
Using 'remote' will: ## TODO
set the source server URL to `$remote_url`.
set the destination server URL to `$local_url`.
* add wakatime key when configuring neovim

View File

@ -1,40 +0,0 @@
#!/bin/sh
export local_domain=''
export local_url=''
export remote_url=''
export local_ssh=''
export remote_ssh=''
export username=''
export webuser=''
export db_root_pass=''
export wp_db_name=''
export wp_db_user=''
export wp_db_pass=''
export wp_path=''
export wp_user=''
export wp_pass=''
# list of themes to install - first one will be activate
export wp_themes=""
export wp_plugins=""
export wp_plugins_active=""
export wp_plugins_uninstall=""
export php_version=''
# set one of
export mariadb_version=''
export mysql_version=''
# set one of
export apache2_version=''
export nginx_version=''
export litespeed_version=''
#set if using litespeed
# https://openlitespeed.org/kb/1-click-install/
# password used to log into litespeed web interface)
export ls_webadmin_pass=''
export ls_lsphp_version=''

4
config/local/apache Normal file
View File

@ -0,0 +1,4 @@
## apache configuration
#
## uncomment if using apache
apache2_version='latest'

13
config/local/litespeed Normal file
View File

@ -0,0 +1,13 @@
## litespeed configuration
## uncomment if using litespeed
## specify specific version from latest, 54, 55, 56, 70, 71, 72, 73 or 74
#export litespeed_version='latest'
## php version
#export ls_lsphp_version='73'
## https://openlitespeed.org/kb/1-click-install/
## password used to log into litespeed web interface
#export ls_webadmin_pass='admin'

9
config/local/local Normal file
View File

@ -0,0 +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'

4
config/local/mariadb Normal file
View File

@ -0,0 +1,4 @@
## uncomment if using mariadb
mariadb_version='latest'
db_root_pass='9483ujtej0--=0FFFdl'

3
config/local/mysql Normal file
View File

@ -0,0 +1,3 @@
## uncomment if using mysql
#mysql_version='latest'
#db_root_pass='9483ujtej0--=0FFFdl'

5
config/local/nginx Normal file
View File

@ -0,0 +1,5 @@
## nginx configuration
## uncomment if using nginx
#nginx_version='latest'

5
config/local/php Normal file
View File

@ -0,0 +1,5 @@
## php configuration
#
## uncomment if using php
php_version='latest'

5
config/local/ssh Normal file
View File

@ -0,0 +1,5 @@
## ssh configuration
## uncomment if connecting via ssh
export ssh='root@test123.home'

6
config/local/user Normal file
View File

@ -0,0 +1,6 @@
## user configuration
## uncomment to set user
export user='ray'
export user_pass='ray'
export group='ray'

23
config/local/wordpress Normal file
View File

@ -0,0 +1,23 @@
## wordpress configuration - uncomment if using wordpress
export wp_user='admin'
export wp_pass='admin'
export wp_email='myemail@isnet.uk'
export wp_version='latest'
export wp_path='/var/www/html/wordpress'
export wp_locale='en_GB'
export wp_title='The WordPress'
export wp_db_name='wordpress'
export wp_db_user='wordpress'
export wp_db_pass='wordpress'
## list of themes to install - first one will be activated
export wp_themes="twentytwenty"
## list of plugins to install
export wp_plugins="akismet all-in-one-seo-pack"
## list of plugins to install and activate
export wp_plugins_active=""

4
config/remote/apache Normal file
View File

@ -0,0 +1,4 @@
## apache configuration
## uncomment if using apache
#apache2_version='latest'

13
config/remote/litespeed Normal file
View File

@ -0,0 +1,13 @@
## litespeed configuration
## uncomment if using litespeed
## specify specific version from latest, 54, 55, 56, 70, 71, 72, 73 or 74
#export litespeed_version='latest'
## php version
#export ls_lsphp_version='73'
## https://openlitespeed.org/kb/1-click-install/
## password used to log into litespeed web interface
#export ls_webadmin_pass='x7__+85676--Dd'

3
config/remote/mariadb Normal file
View File

@ -0,0 +1,3 @@
## uncomment if using mariadb
#mariadb_version='latest'

2
config/remote/mysql Normal file
View File

@ -0,0 +1,2 @@
## uncomment if using mysql
#mysql_version='latest'

5
config/remote/nginx Normal file
View File

@ -0,0 +1,5 @@
## nginx configuration
## uncomment if using nginx
#nginx_version='latest'

5
config/remote/php Normal file
View File

@ -0,0 +1,5 @@
## php configuration
#
## uncomment if using php
#php_version='latest'

6
config/remote/remote Normal file
View File

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

5
config/remote/ssh Normal file
View File

@ -0,0 +1,5 @@
## ssh configuration
## uncomment if connecting via ssh
#export ssh='root@test123.example.com'

7
config/remote/user Normal file
View File

@ -0,0 +1,7 @@
## user configuration
## uncomment to set user
## webuser/webgroup
## leave commented for default
#export webuser='www-data'
#export webgroup='www-data'

24
config/remote/wordpress Normal file
View File

@ -0,0 +1,24 @@
## wordpress configuration - uncomment if using wordpress
# export wp_user='admin'
# export wp_pass=''
## leave commented if using default
# export wp_path='/var/www/html/wordpress'
# export db_root_pass='9dn,s93j_UU9--s889d8dUY'
# export wp_db_name='wordpress'
# export wp_db_user='wordpress'
# export wp_db_pass='__d39fhi3nkjdflk8-ddWEs'
## list of themes to install - first one will be activate
# export wp_themes="twentytwenty"
## list of plugins to install
# export wp_plugins=""
## list of plugins to activate
# export wp_plugins_active=""
## list of plugins to uninstall
# export wp_plugins_uninstall="hello aksimet"

View File

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

0
export-to-remote.sh Executable file
View File

0
import-from-remote.sh Executable file
View File

60
install-local.sh Executable file
View File

@ -0,0 +1,60 @@
#!/bin/sh
# default scripts to use
_script_dir='./scripts/debian10'
if [ -n "$1" ] ; then
_script_dir="./scripts/$1"
if ! [ -d "$_script_dir" ] ; then
echo "Error: script directory not found '$_script_dir'"
exit 1
fi
fi
echo "Using Scripts in: $_script_dir"
# source our config files
for _file in ./config/local/* ; do
. "$_file"
done
# check we have ssh access
[ -z "$ssh" ] && echo "Error: no ssh configuration specified" && exit 5
# update local server
echo "Updating ..":
ssh -T $ssh << EOSSH
apt-get update && apt-get upgrade
EOSSH
echo "Update complete"
. "$_script_dir/install-user.sh"
. "$_script_dir/install-base.sh"
if [ -n "$php_version" ] ; then
. "$_script_dir/install-php.sh"
fi
if [ -n "$mariadb_version" ] ; then
. "$_script_dir/install-mariadb.sh"
elif [ -n "$mysql_version" ] ; then
. "$_script_dir/install-mysql.sh"
fi
if [ -n "$apache2_version" ] ; then
. "$_script_dir/install-apache2.sh"
elif [ -n "$nginx_version" ] ; then
# TODO nginx install script
echo 'TODO - nginx install script'
elif [ -n "$litespeed_version" ] ; then
# TODO
echo 'TODO litespeed install script'
fi
if [ -n "$wp_user" ] ; then
. "$_script_dir/install-wordpress.sh"
fi
if [ -n "$dev_env" ] ; then
. "$_script_dir/install-dev-base.sh"
fi

0
install-remote.sh Executable file
View File

38
old/server-install-litespeed.sh Executable file
View File

@ -0,0 +1,38 @@
#!/bin/sh
if [ -z "$1" ] ; then
echo "error: must specify configuration file to use"
exit 5
fi
. ./"$1"
ssh -T $ssh << EOSSH
ufw allow http && ufw allow https
if [ "$litespeed_version" != 'latest' ] ; then
echo "TODO install specific litespeed version"
echo ""
echo "Specify \"litespeed_version='latest'\" to install current version."
exit 1
fi
if [ -n "$wp_user" ] ; then
wget --no-check-certificate https://raw.githubusercontent.com/litespeedtech/ols1clk/master/ols1clk.sh && bash ols1clk.sh \
--adminpassword "$ls_webadmin_pass" \
--lsphp "$ls_lsphp_version" \
--wordpressplus "$url" \
--wordpresspath "$wp_path" \
--dbrootpassword "$db_root_pass" \
--dbpassword "$wp_db_pass" \
--dbname "$wp_db_name" \
--dbuser "$wp_db_user" \
--wpuser "$wp_user" \
--wppassword "$wp_pass" \
&& ufw allow 7080
else
echo "TODO install litespeed without WordPress"
exit 1
fi
EOSSH

17
old/server-install-nginx.sh Executable file
View File

@ -0,0 +1,17 @@
#!/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 nginx"
exit 1
EOSSH

View File

@ -0,0 +1,20 @@
#!/bin/sh
if [ "$apache2_version" != 'latest' ] ; then
echo 'ERROR: unable to install Apache2 - only '"'latest'"' version currently supported'
exit 30
fi
ssh -T $ssh << EOSSH
echo "Installing Apache2"
apt install -y apache2
ufw allow in "WWW Full"
sed -i '/export APACHE_RUN_USER=/c\export APACHE_RUN_USER='"$user" /etc/apache2/envvars
sed -i '/export APACHE_RUN_GROUP=/c\export APACHE_RUN_GROUP='"$group" /etc/apache2/envvars
chown -R "$user:$group" "/var/www/html"
echo "Nothing here ..." > /var/www/html/index.html
systemctl restart apache2
EOSSH

View File

@ -0,0 +1,15 @@
#!/bin/sh
ssh -T $ssh << EOSSH
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
apt install -y ufw || (echo "ERROR while installing ufw" ; exit 15)
ufw allow ssh || (echo "Error while configuring ufw to allow ssh" ; exit 20 )
yes | ufw enable
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

@ -0,0 +1,26 @@
#!/bin/sh
if [ "$mariadb_version" != 'latest' ] ; then
echo 'ERROR: unable to install MariaDB - only '"'latest'"' version currently supported'
exit 30
fi
_mysql_cmd="mysql -uroot -e "
ssh -T $ssh << EOSSH
if mysql --version ; then
echo "ERROR: unable to install MariaDb, 'mysql' already installed - aborting install"
exit 35
fi
echo "Installing MariaDB"
apt install -y mariadb-server
$_mysql_cmd "DELETE FROM mysql.user WHERE User='';"
$_mysql_cmd "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');"
$_mysql_cmd "DROP DATABASE IF EXISTS test;"
$_mysql_cmd "DELETE FROM mysql.db WHERE Db='test' OR Db='"'test\\_%'"'"
mysqladmin --user=root password "$db_root_pass"
mysqladmin --user=root --password="$db_root_pass" flush-privileges
EOSSH

View File

@ -0,0 +1,26 @@
#!/bin/sh
if [ "$mysql_version" != 'latest' ] ; then
echo 'ERROR: unable to install MySQL - only '"'latest'"' version currently supported'
exit 30
fi
_mysql_cmd="mysql -uroot -e "
ssh -T $ssh << EOSSH
if mysql --version ; then
echo "ERROR: unable to install MySQL, 'mysql' already installed - aborting install"
exit 35
fi
echo "Installing MySQL"
apt install -y mysql-server
$_mysql_cmd "DELETE FROM mysql.user WHERE User='';"
$_mysql_cmd "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');"
$_mysql_cmd "DROP DATABASE IF EXISTS test;"
$_mysql_cmd "DELETE FROM mysql.db WHERE Db='test' OR Db='"'test\\_%'"'"
mysqladmin --user=root password "$db_root_pass"
mysqladmin --user=root --password="$db_root_pass" flush-privileges
EOSSH

28
scripts/debian10/install-php.sh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/sh
if [ "$php_version" != 'latest' ] ; then
echo 'ERROR: unable to install PHP - only '"'latest'"' version currently supported'
exit 30
fi
if [ -n "$wp_user" ] ; then
echo 'Installing PHP for WordPress ...'
ssh -T $ssh << 'EOSSH'
apt install -y php libapache2-mod-php php-fpm php-bcmath php-curl php-gd php-imagick php-mbstring \
php-mysql php-soap php-xml php-zip
_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"
EOSSH
else
echo 'Installing default PHP ...'
ssh -T $ssh << EOSSH
apt install -y php libapache2-mod-php php-mysql
EOSSH
fi

View File

@ -0,0 +1,54 @@
#!/bin/sh
_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
echo "Creating user .."
useradd -m -d "$_home_dir" "$user"
echo "$user:$user_pass" | chpasswd
usermod -aG sudo "$user"
mkdir -p "$_home_dir/.ssh"
cp /root/.ssh/authorized_keys "$_home_dir/.ssh/authorized_keys"
chown -R "$user:$group" "$_home_dir/.ssh"
echo "Cloning configuration files .."
su "$user"
mkdir -p "$_home_dir/.config"
if [ -e "$_home_dir/.config/profile" ] ; then
mv "$_home_dir/.config/profile" "$_home_dir/.config/profile-original-$(date +%s)"
fi
git clone https://git.rayelliott.dev/dots/profile.git "$_home_dir/.config/profile"
"$_home_dir/.config/profile/install.sh"
if [ -e "$_home_dir/.config/tmux" ] ; then
mv "$_home_dir/.config/tmux" "$_home_dir/.config/tmux-original-$(date +%s)"
fi
git clone https://git.rayelliott.dev/dots/tmux.git "$_home_dir/.config/tmux"
"$_home_dir/.config/tmux/install.sh"
if [ -e "$_home_dir/.config/zsh" ] ; then
mv "$_home_dir/.config/zsh" "$_home_dir/.config/zsh-original-$(date +%s)"
fi
git clone https://git.rayelliott.dev/dots/zsh.git "$_home_dir/.config/zsh"
"$_home_dir/.config/zsh/install.sh"
EOSSH
ssh -T $ssh << EOSSH
chsh -s /usr/bin/zsh "$user"
EOSSH

View File

@ -0,0 +1,126 @@
echo "Installing WordPress .."
_mysql_cmd="mysql -uroot -p$db_root_pass -e "
ssh -T $ssh << EOSSH
# 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
su "$user"
if wp core is-installed --quiet --path="$wp_path" ; then
echo "WordPress already installed"
else
# first create database and user
if command -v mysql ; then
$_mysql_cmd "CREATE DATABASE $wp_db_name;"
$_mysql_cmd "GRANT ALL PRIVILEGES ON $wp_db_name.* TO '$wp_db_user'@'localhost' IDENTIFIED BY '$wp_db_pass';"
$_mysql_cmd "FLUSH PRIVILEGES;"
else
echo "ERROR: no installed database found - aborting WordPress install"
exit 40
fi
wp core download \
--version="$wp_version" \
--path="$wp_path" \
--skip-content \
--locale="$wp_locale"
wp config create \
--path="$wp_path" \
--dbname="$wp_db_name" \
--dbuser="$wp_db_user" \
--dbpass="$wp_db_pass" \
--locale="$wp_locale" \
--extra-php <<PHP
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
PHP
wp core install \
--path="$wp_path" \
--url="$domain" \
--title="$wp_title" \
--admin_user="$wp_user" \
--admin_password="$wp_pass" \
--admin_email="$wp_email"
fi
EOSSH
if [ -n "$wp_themes" ] ; then
printf "\nInstalling themes ..."
option='--activate'
for theme in $wp_themes ; do
echo " installing $theme ..."
ssh -T $ssh << EOSSH
su "$user"
wp theme install $theme "$option" --path="$wp_path"
EOSSH
option=''
done
fi
if [ -n "$wp_plugins" ] ; then
printf "\nInstalling plugins ..."
for plugin in $wp_plugins ; do
echo " installing $plugin ..."
ssh -T $ssh << EOSSH
su "$user"
wp plugin install $plugin --path="$wp_path"
EOSSH
done
fi
if [ -n "$wp_plugins_active" ] ; then
printf "\nInstalling plugins to activate ..."
for plugin in $wp_plugins_active ; do
echo " installing $plugin ..."
ssh -T $ssh << EOSSH
su "$user"
wp plugin install $plugin --activate --path="$wp_path"
EOSSH
done
fi
if [ -n "$wp_plugins_active" ] ; then
printf "\nUninstalling plugins ..."
for plugin in $wp_plugins_uninstall ; do
echo " installing $plugin ..."
ssh -T $ssh << EOSSH
su "$user"
wp plugin deactivate $plugin --path="$wp_path"
wp plugin uninstall $plugin --path="$wp_path"
EOSSH
done
fi
config_path='/etc/apache2/sites-available/wordpress.conf'
ssh -T $ssh << EOSSH
if [ -n "$apache2_version" ] ; then
mkdir -p /var/log/wordpress/
cat << EOF > $config_path
<VirtualHost *:80>
ServerName $domain
DocumentRoot $wp_path
ErrorLog /var/log/wordpress/error.log
CustomLog /var/log/wordpress/access.log combined
<Directory $wp_path/>
AllowOverride All
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
</Directory>
</VirtualHost>
EOF
a2enmod rewrite
a2ensite wordpress
a2dissite 000-default
systemctl reload apache2
fi
EOSSH

View File

@ -1,32 +0,0 @@
#!/bin/sh
. ./config
if [ "$1" = 'local' ] ; then
src_url="$local_url";
dest_url="$remote_url";
src_ssh="$local_ssh"
elif [ "$1" = 'remote' ] ; then
src_url="$remote_url";
dest_url="$local_url";
src_ssh="$remote_ssh"
else
echo "error: must specify local or remote"
exit 5
fi
ssh -T $src_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,59 +0,0 @@
#!/bin/sh
. ./config
if [ "$1" = 'local' ] ; then
src_url="$local_url";
dest_url="$remote_url";
src_ssh="$local_ssh"
elif [ "$1" = 'remote' ] ; then
src_url="$remote_url";
dest_url="$local_url";
src_ssh="$remote_ssh"
else
echo "error: must specify local or remote"
exit 5
fi
ssh -T $src_ssh << EOSSH
ufw allow http && ufw allow https
if [ -n "$apache2_version" ] ; then
echo "TODO install apache"
exit 1
elif [ -n "$nginx_version" ] ; then
echo "TODO install nginx"
exit 1
elif [ -n "$litespeed_version" ] ; then
if [ "$litespeed_version" != 'latest' ] ; then
echo "TODO install specific litespeed version"
echo ""
echo "Specify \"litespeed_version='latest'\" to install current version."
exit 1
fi
if [ -n "$wp_user" ] ; then
wget --no-check-certificate https://raw.githubusercontent.com/litespeedtech/ols1clk/master/ols1clk.sh && bash ols1clk.sh \
--adminpassword "$ls_webadmin_pass" \
--lsphp "$ls_lsphp_version" \
--wordpressplus "$src_url" \
--wordpresspath "$wp_path" \
--dbrootpassword "$db_root_pass" \
--dbpassword "$wp_db_pass" \
--dbname "$wp_db_name" \
--dbuser "$wp_db_user" \
--wpuser "$wp_user" \
--wppassword "$wp_pass" \
&& ufw allow 7080
else
echo "TODO install litespeed without WordPress"
exit 1
fi
else
echo "$0: Error - no webserver specified in configuration"
exit 5
fi
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,88 +0,0 @@
#!/bin/sh
. ./config
if [ "$1" = 'local' ] ; then
src_url="$local_url";
dest_url="$remote_url";
src_ssh="$local_ssh"
elif [ "$1" = 'remote' ] ; then
src_url="$remote_url";
dest_url="$local_url";
src_ssh="$remote_ssh"
else
echo "error: must specify local or remote"
exit 5
fi
ssh -T $src_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