Bestanden uploaden naar 'resources'
meer oude bestanden
This commit is contained in:
82
resources/Apache_v1.0.sh
Normal file
82
resources/Apache_v1.0.sh
Normal file
@@ -0,0 +1,82 @@
|
||||
#==============================================================================
|
||||
# UBUNTU 18.04 BASH SCRIPT
|
||||
#==============================================================================
|
||||
# top -o %MEM -> See Memory consumption
|
||||
# apt-get update -y && apt-get upgrade -y && apt-get dist-upgrade -y
|
||||
# do-release-upgrade -d
|
||||
#
|
||||
# BENCHMARK
|
||||
# wget freevps.us/downloads/bench.sh -O - -o /dev/null|bash
|
||||
# wget –no-check-certificate https://vhwinfo.com/vhwinfo.sh -O - -o /dev/null|bash
|
||||
#
|
||||
# NGINX LOG -->> tail -n 100 /var/log/nginx/error.log
|
||||
# RSYNC -->> sshpass -p 'passwd' rsync /tmp/backups/. root@51.68.230.92:/tmp --delete -av --ignore-existing
|
||||
# WGET .SH -->> http://sitehere.com/install.sh -v -O install.sh && ./install.sh; rm -rf install.sh
|
||||
#
|
||||
#==============================================================================
|
||||
# UNDER DEVELOPMENT
|
||||
#==============================================================================
|
||||
#
|
||||
#==============================================================================
|
||||
# CHECKEN!
|
||||
# >
|
||||
#==============================================================================
|
||||
echo Welk domein mag gekoppeld worden? Typ domein zonder www
|
||||
read domain
|
||||
echo Standaard wachtwoord
|
||||
read passwd
|
||||
echo administrator email
|
||||
read email
|
||||
apt-get update
|
||||
apt-get upgrade -y
|
||||
apt-get dist-upgrade -y
|
||||
apt-get clean
|
||||
apt-get autoremove -y
|
||||
hostnamectl set-hostname $domain
|
||||
sed -i 's/;preserve_hostname: false/preserve_hostname: true/g' /etc/cloud/cloud.cfg
|
||||
timedatectl set-timezone Europe/Amsterdam
|
||||
ufw allow OpenSSH
|
||||
ufw allow 443/tcp
|
||||
ufw allow 80/tcp
|
||||
ufw limit ssh
|
||||
echo "y" | sudo ufw enable
|
||||
sed -i 's/#/vm.swappiness=10/g' /etc/sysctl.conf
|
||||
sed -i 's/#/vm.vfs_cache_pressure=50/g' /etc/sysctl.conf
|
||||
#-------------------#
|
||||
# LAMP #
|
||||
#-------------------#
|
||||
install apache2 -y
|
||||
apt install mysql-server-5.7 -y
|
||||
mysql_secure_installation
|
||||
mysql -u root -p"$passwd" -e "SELECT user,authentication_string,plugin,host FROM mysql.user;"
|
||||
mysql -u root -p"$passwd" -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '"$passwd"';"
|
||||
mysql -u root -p"$passwd" -e "FLUSH PRIVILEGES;"
|
||||
mysql -u root -p"$passwd" -e "SELECT user,authentication_string,plugin,host FROM mysql.user;"
|
||||
apt install libapache2-mod-php php-fpm php-mysql php-cgi php-common php-pear php-mbstring php-curl php-gd php-intl php-soap php-xml php-xmlrpc php-zip -y
|
||||
cat <<EOF > /etc/apache2/mods-enabled/dir.conf
|
||||
<IfModule mod_dir.c>
|
||||
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
|
||||
</IfModule>
|
||||
EOF
|
||||
systemctl restart apache2
|
||||
systemctl status apache2
|
||||
#-------------------#
|
||||
# VIRTUAL HOST #
|
||||
#-------------------#
|
||||
rm /var/www/html
|
||||
mkdir -p /var/www/"$domain"/public_html
|
||||
chmod -R 755 /var/www
|
||||
cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/"$domain".conf
|
||||
cat <<EOF > /etc/apache2/sites-available/"$domain".conf
|
||||
<VirtualHost *:80>
|
||||
ServerAdmin $email
|
||||
ServerName $domain
|
||||
ServerAlias www.$domain
|
||||
DocumentRoot /var/www/$domain/public_html
|
||||
ErrorLog \${APACHE_LOG_DIR}/error.log
|
||||
CustomLog \${APACHE_LOG_DIR}/access.log combined
|
||||
</VirtualHost>
|
||||
EOF
|
||||
a2ensite $domain.conf
|
||||
a2dissite 000-default.conf
|
||||
systemctl restart apache2
|
||||
107
resources/backup.sh
Normal file
107
resources/backup.sh
Normal file
@@ -0,0 +1,107 @@
|
||||
#!/bin/bash
|
||||
#==============================================================================
|
||||
SHELL=/bin/sh
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
# 0 2 * * * /bin/bash /tmp/backup.sh
|
||||
|
||||
#sshpass -p 'ictmaatwerk' rsync /tmp/backups/. root@51.68.230.92:/tmp --delete -av --ignore-existing
|
||||
|
||||
#==============================================================================
|
||||
# CUSTOM SETTINGS
|
||||
#==============================================================================
|
||||
|
||||
# directory to put the backup files
|
||||
BACKUP_DIR=/backup
|
||||
|
||||
# MYSQL Parameters
|
||||
MYSQL_UNAME=root
|
||||
MYSQL_PWORD=Lithops2206
|
||||
|
||||
# Don't backup databases with these names
|
||||
# Example: starts with mysql (^mysql) or ends with _schema (_schema$)
|
||||
IGNORE_DB="(^mysql|_schema$)"
|
||||
|
||||
# include mysql and mysqldump binaries for cron bash user
|
||||
PATH=$PATH:/usr/local/mysql/bin
|
||||
|
||||
# Number of days to keep backups
|
||||
KEEP_BACKUPS_FOR=30 #days
|
||||
|
||||
#==============================================================================
|
||||
# METHODS
|
||||
#==============================================================================
|
||||
|
||||
# YYYY-MM-DD
|
||||
TIMESTAMP=$(date +%F_%H:%M)
|
||||
|
||||
function delete_old_backups()
|
||||
{
|
||||
# Delete mysql older x days
|
||||
echo "Deleting $BACKUP_DIR/*.sql.gz older than $KEEP_BACKUPS_FOR days"
|
||||
find $BACKUP_DIR -type f -name "*.sql.gz" -mtime +$KEEP_BACKUPS_FOR -exec rm {} \;
|
||||
# Delete html folder older x days
|
||||
echo "Deleting $BACKUP_DIR/*.tar.gz older than $KEEP_BACKUPS_FOR days"
|
||||
find $BACKUP_DIR -type f -name "*.tar.gz" -mtime +$KEEP_BACKUPS_FOR -exec rm {} \;
|
||||
}
|
||||
|
||||
function mysql_login() {
|
||||
local mysql_login="-u $MYSQL_UNAME"
|
||||
if [ -n "$MYSQL_PWORD" ]; then
|
||||
local mysql_login+=" -p$MYSQL_PWORD"
|
||||
fi
|
||||
echo $mysql_login
|
||||
}
|
||||
|
||||
function database_list() {
|
||||
local show_databases_sql="SHOW DATABASES WHERE \`Database\` NOT REGEXP '$IGNORE_DB'"
|
||||
echo $(mysql $(mysql_login) -e "$show_databases_sql"|awk -F " " '{if (NR!=1) print $1}')
|
||||
}
|
||||
|
||||
function echo_status(){
|
||||
printf '\r';
|
||||
printf ' %0.s' {0..100}
|
||||
printf '\r';
|
||||
printf "$1"'\r'
|
||||
}
|
||||
|
||||
function backup_database(){
|
||||
backup_file="$BACKUP_DIR/$TIMESTAMP.$database.sql.gz"
|
||||
output+="$database => $backup_file\n"
|
||||
echo_status "...backing up $count of $total databases: $database"
|
||||
$(mysqldump $(mysql_login) $database | gzip -9 > $backup_file)
|
||||
}
|
||||
|
||||
function backup_databases(){
|
||||
local databases=$(database_list)
|
||||
local total=$(echo $databases | wc -w | xargs)
|
||||
local output=""
|
||||
local count=1
|
||||
for database in $databases; do
|
||||
backup_database
|
||||
local count=$((count+1))
|
||||
done
|
||||
echo -ne $output | column -t
|
||||
}
|
||||
|
||||
function hr(){
|
||||
printf '=%.0s' {1..100}
|
||||
printf "\n"
|
||||
}
|
||||
|
||||
#==============================================================================
|
||||
# RUN SCRIPT
|
||||
#==============================================================================
|
||||
mkdir -p /backup
|
||||
chmod -R 755 /backup
|
||||
# MYSQL DUMP
|
||||
delete_old_backups
|
||||
hr
|
||||
backup_databases
|
||||
hr
|
||||
# DIRECTORY BACKUP
|
||||
BACKUPTIME=`date +%b-%d-%y` #get the current date
|
||||
DESTINATION=/backup/backup-$BACKUPTIME.tar.gz #create a backup file using the current date in it's name
|
||||
SOURCEFOLDER=/var/www #the folder that contains the files that we want to backup
|
||||
tar -cpzf $DESTINATION $SOURCEFOLDER #create the backup
|
||||
|
||||
printf "All backed up!\n\n"
|
||||
101
resources/mysql.sh
Normal file
101
resources/mysql.sh
Normal file
@@ -0,0 +1,101 @@
|
||||
#!/bin/bash
|
||||
#==============================================================================
|
||||
SHELL=/bin/sh
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
# 0 2 * * * /bin/bash /tmp/backup.sh
|
||||
|
||||
#RSYNC -> sshpass -p 'ictmaatwerk' rsync /tmp/backups/. root@51.68.230.92:/tmp --delete -av --ignore-existing
|
||||
|
||||
#==============================================================================
|
||||
# CUSTOM SETTINGS
|
||||
#==============================================================================
|
||||
|
||||
# directory to put the backup files
|
||||
BACKUP_DIR=/backup
|
||||
|
||||
# MYSQL Parameters
|
||||
MYSQL_UNAME=root
|
||||
MYSQL_PWORD=ictmaatwerk
|
||||
|
||||
# Don't backup databases with these names
|
||||
# Example: starts with mysql (^mysql) or ends with _schema (_schema$)
|
||||
IGNORE_DB="(^mysql|_schema$)"
|
||||
|
||||
# include mysql and mysqldump binaries for cron bash user
|
||||
PATH=$PATH:/usr/local/mysql/bin
|
||||
|
||||
# Number of days to keep backups
|
||||
KEEP_BACKUPS_FOR=30 #days
|
||||
|
||||
#==============================================================================
|
||||
# METHODS
|
||||
#==============================================================================
|
||||
|
||||
# YYYY-MM-DD
|
||||
TIMESTAMP=$(date +%F_%H:%M)
|
||||
|
||||
function delete_old_backups()
|
||||
{
|
||||
# Delete mysql older x days
|
||||
echo "Deleting $BACKUP_DIR/*.sql.gz older than $KEEP_BACKUPS_FOR days"
|
||||
find $BACKUP_DIR -type f -name "*.sql.gz" -mtime +$KEEP_BACKUPS_FOR -exec rm {} \;
|
||||
# Delete html folder older x days
|
||||
echo "Deleting $BACKUP_DIR/*.tar.gz older than $KEEP_BACKUPS_FOR days"
|
||||
find $BACKUP_DIR -type f -name "*.tar.gz" -mtime +$KEEP_BACKUPS_FOR -exec rm {} \;
|
||||
}
|
||||
|
||||
function mysql_login() {
|
||||
local mysql_login="-u $MYSQL_UNAME"
|
||||
if [ -n "$MYSQL_PWORD" ]; then
|
||||
local mysql_login+=" -p$MYSQL_PWORD"
|
||||
fi
|
||||
echo $mysql_login
|
||||
}
|
||||
|
||||
function database_list() {
|
||||
local show_databases_sql="SHOW DATABASES WHERE \`Database\` NOT REGEXP '$IGNORE_DB'"
|
||||
echo $(mysql $(mysql_login) -e "$show_databases_sql"|awk -F " " '{if (NR!=1) print $1}')
|
||||
}
|
||||
|
||||
function echo_status(){
|
||||
printf '\r';
|
||||
printf ' %0.s' {0..100}
|
||||
printf '\r';
|
||||
printf "$1"'\r'
|
||||
}
|
||||
|
||||
function backup_database(){
|
||||
backup_file="$BACKUP_DIR/$TIMESTAMP.$database.sql.gz"
|
||||
output+="$database => $backup_file\n"
|
||||
echo_status "...backing up $count of $total databases: $database"
|
||||
$(mysqldump $(mysql_login) $database | gzip -9 > $backup_file)
|
||||
}
|
||||
|
||||
function backup_databases(){
|
||||
local databases=$(database_list)
|
||||
local total=$(echo $databases | wc -w | xargs)
|
||||
local output=""
|
||||
local count=1
|
||||
for database in $databases; do
|
||||
backup_database
|
||||
local count=$((count+1))
|
||||
done
|
||||
echo -ne $output | column -t
|
||||
}
|
||||
|
||||
function hr(){
|
||||
printf '=%.0s' {1..100}
|
||||
printf "\n"
|
||||
}
|
||||
|
||||
#==============================================================================
|
||||
# RUN SCRIPT
|
||||
#==============================================================================
|
||||
mkdir -p /backup
|
||||
chmod -R 755 /backup
|
||||
# MYSQL DUMP
|
||||
delete_old_backups
|
||||
hr
|
||||
backup_databases
|
||||
hr
|
||||
printf "All backed up!\n\n"
|
||||
32
resources/sftp_without_root.sh
Normal file
32
resources/sftp_without_root.sh
Normal file
@@ -0,0 +1,32 @@
|
||||
#==============================================================================
|
||||
# UBUNTU 18.04 - SFTP ACCES WITHOUT ROOT OR SSH
|
||||
# https://www.digitalocean.com/community/tutorials/how-to-enable-sftp-without-shell-access-on-ubuntu-18-04
|
||||
#==============================================================================
|
||||
echo Username?
|
||||
read user
|
||||
echo domein voor toegang?
|
||||
read domain
|
||||
adduser $user
|
||||
chown root:root /var/www
|
||||
chmod 755 /var/www
|
||||
chown $user:$user /var/www/$domain
|
||||
cat <<EOF > /etc/ssh/sshd_config
|
||||
PasswordAuthentication yes
|
||||
ChallengeResponseAuthentication no
|
||||
UsePAM yes
|
||||
X11Forwarding yes
|
||||
PrintMotd no
|
||||
AcceptEnv LANG LC_*
|
||||
Subsystem sftp /usr/lib/openssh/sftp-server
|
||||
|
||||
PermitRootLogin yes
|
||||
Match User $user
|
||||
ForceCommand internal-sftp
|
||||
PasswordAuthentication yes
|
||||
ChrootDirectory /var/www
|
||||
PermitTunnel no
|
||||
AllowAgentForwarding no
|
||||
AllowTcpForwarding no
|
||||
X11Forwarding no
|
||||
EOF
|
||||
systemctl restart sshd
|
||||
78
resources/wordpress.sh
Normal file
78
resources/wordpress.sh
Normal file
@@ -0,0 +1,78 @@
|
||||
#==============================================================================
|
||||
# INSTALL SECOND WEBSITE WITH WORDPRESS
|
||||
#==============================================================================
|
||||
echo Welk domein mag gekoppeld worden? Typ domein zonder www
|
||||
read domain
|
||||
echo Standaard wachtwoord?
|
||||
read passwd
|
||||
echo Database user en name?
|
||||
read db_name db_user
|
||||
echo Standaard wachtwoord
|
||||
read passwd
|
||||
db_pass=$(date +%s|sha256sum|base64|head -c 32)
|
||||
#-------------------#
|
||||
# MYSQL CONFIG #
|
||||
#-------------------#
|
||||
mysql -u root -p"$passwd" -e "CREATE DATABASE "$db_name" DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;"
|
||||
mysql -u root -p"$passwd" -e "GRANT ALL ON "$db_name".* TO '"$db_user"'@'localhost' IDENTIFIED BY '"$db_pass"';"
|
||||
mysql -u root -p"$passwd" -e "FLUSH PRIVILEGES;"
|
||||
#-------------------#
|
||||
# WP - INSTALL #
|
||||
#-------------------#
|
||||
cd /tmp
|
||||
curl -LO https://wordpress.org/latest.tar.gz
|
||||
tar xzvf latest.tar.gz
|
||||
cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php
|
||||
cp -a /tmp/wordpress/. /var/www/"$domain"/html
|
||||
chown -R www-data:www-data /var/www/"$domain"/html
|
||||
WPSalts=$(wget https://api.wordpress.org/secret-key/1.1/salt/ -q -O -)
|
||||
cat <<EOF > /var/www/"$domain"/html/wp-config.php
|
||||
<?php
|
||||
define('DB_NAME', '$db_name');
|
||||
define('DB_USER', '$db_user');
|
||||
define('DB_PASSWORD', '$db_pass');
|
||||
define('DB_HOST', 'localhost');
|
||||
define('DB_CHARSET', 'utf8');
|
||||
define('DB_COLLATE', '');
|
||||
#define( 'WP_SITEURL', '' );
|
||||
#define( 'WP_HOME', '' );
|
||||
#define( 'ALTERNATE_WP_CRON', true );
|
||||
#define('DISABLE_WP_CRON', 'true');
|
||||
#define('WP_CRON_LOCK_TIMEOUT', 900);
|
||||
#define('AUTOSAVE_INTERVAL', 300);
|
||||
define( 'WP_MEMORY_LIMIT', '256M' );
|
||||
#define( 'FS_CHMOD_DIR', ( 0755 & ~ umask() ) );
|
||||
#define( 'FS_CHMOD_FILE', ( 0644 & ~ umask() ) );
|
||||
#define( 'WP_ALLOW_REPAIR', true );
|
||||
#define( 'FORCE_SSL_ADMIN', true );
|
||||
#define( 'AUTOMATIC_UPDATER_DISABLED', true );
|
||||
#define( 'WP_AUTO_UPDATE_CORE', false );
|
||||
$WPSalts
|
||||
\$table_prefix = '$db_name';
|
||||
|
||||
define('WP_DEBUG', false);
|
||||
if ( !defined('ABSPATH') )
|
||||
define('ABSPATH', dirname(__FILE__) . '/');
|
||||
|
||||
#\$memcached_servers = array(
|
||||
# 'default' => array(
|
||||
# '127.0.0.1:11211'
|
||||
# )
|
||||
#);
|
||||
#define('WP_REDIS_HOST', '127.0.0.1');
|
||||
#define('WP_REDIS_PASSWORD', '$passwd');
|
||||
#define('WP_REDIS_PORT', '6379');
|
||||
require_once(ABSPATH . 'wp-settings.php');
|
||||
EOF
|
||||
#-------------------#
|
||||
# OPCACHE GUI #
|
||||
#-------------------#
|
||||
cd /tmp
|
||||
curl -LO https://raw.githubusercontent.com/amnuts/opcache-gui/master/index.php
|
||||
cp /tmp/index.php /tmp/opcache.php
|
||||
cp -a /tmp/opcache.php /var/www/"$domain"/html
|
||||
cat > /var/www/"$domain"/html/info.php <<- "EOF"
|
||||
<?php
|
||||
phpinfo();
|
||||
?>
|
||||
EOF
|
||||
Reference in New Issue
Block a user