improve install and add magento upgrade
This commit is contained in:
parent
0161e3b226
commit
f9b8f2cca7
|
@ -1,11 +1,13 @@
|
|||
# bashrc
|
||||
|
||||
## mybashrc install
|
||||
|
||||
```bash
|
||||
bash <(curl -sL virtubox.net/mybashrc || wget -O - virtubox.net/mybashrc)
|
||||
```
|
||||
|
||||
## netdata install
|
||||
|
||||
```bash
|
||||
bash <(curl -sL https://git.virtubox.net/virtubox/bashrc/raw/branch/master/netdata.sh || wget -O - https://git.virtubox.net/virtubox/bashrc/raw/branch/master/netdata.sh)
|
||||
```
|
||||
|
||||
```
|
150
mybashrc
150
mybashrc
|
@ -8,7 +8,7 @@ if [ "$(id -u)" != "0" ]; then
|
|||
NEED_SUDO="/usr/bin/sudo"
|
||||
else
|
||||
NEED_SUDO=""
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
@ -34,8 +34,8 @@ EE_MYSQL_OPTIMIZATION() {
|
|||
|
||||
if [ -f $HOME/.my.cnf ]; then
|
||||
/usr/bin/mysqlcheck -Aos --auto-repair
|
||||
elif [ -f /etc/psa/.psa.shadow ]; then
|
||||
MYSQL_PWD="$(cat /etc/psa/.psa.shadow)" /usr/bin/mysqlcheck -Aos -uadmin --auto-repair
|
||||
elif [ -f /etc/psa/.psa.shadow ]; then
|
||||
MYSQL_PWD="$(cat /etc/psa/.psa.shadow)" /usr/bin/mysqlcheck -Aos -uadmin --auto-repair
|
||||
else
|
||||
echo "$HOME/.my.cnf or /etc/psa/.psa.shadow doesn't exist"
|
||||
fi
|
||||
|
@ -85,20 +85,20 @@ DD_BENCHMARK_DISK() {
|
|||
|
||||
ffmpeg_start_time() {
|
||||
|
||||
if [ "${#}" = "0" ]; then
|
||||
echo "ffmpeg-cut-start <start-time> <input> <duration(optional)>"
|
||||
echo ""
|
||||
echo "example : ffmpeg-cut-start 00:34:24.85 file.mp4 300"
|
||||
else
|
||||
if [ "${#}" = "0" ]; then
|
||||
echo "ffmpeg-cut-start <start-time> <input> <duration(optional)>"
|
||||
echo ""
|
||||
echo "example : ffmpeg-cut-start 00:34:24.85 file.mp4 300"
|
||||
else
|
||||
|
||||
FFMPEG_ARGS="-ss "$2" -i "$1""
|
||||
if [ "$3" ]; then
|
||||
FFMPEG_ARGS="$FFMPEG_ARGS -time $3 -c copy -movflags +faststart ${1%.mp4}-output.mp4"
|
||||
else
|
||||
FFMPEG_ARGS="$FFMPEG_ARGS -c copy -movflags +faststart ${1%.mp4}-output.mp4"
|
||||
fi
|
||||
/usr/bin/ffmpeg "$FFMPEG_ARGS"
|
||||
fi
|
||||
FFMPEG_ARGS="-ss "$2" -i "$1""
|
||||
if [ "$3" ]; then
|
||||
FFMPEG_ARGS="$FFMPEG_ARGS -time $3 -c copy -movflags +faststart ${1%.mp4}-output.mp4"
|
||||
else
|
||||
FFMPEG_ARGS="$FFMPEG_ARGS -c copy -movflags +faststart ${1%.mp4}-output.mp4"
|
||||
fi
|
||||
/usr/bin/ffmpeg "$FFMPEG_ARGS"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
@ -114,58 +114,58 @@ MAINTENANCE_APT() {
|
|||
|
||||
if [ "$(id -u)" = "0" ] || [ -n "$IS_SUDOERS" ]; then
|
||||
|
||||
echo -e "${CGREEN}#############################################${CEND}"
|
||||
echo -e ' APT UPDATE '
|
||||
echo -e "${CGREEN}#############################################${CEND}"
|
||||
$NEED_SUDO apt-get update
|
||||
echo -e "${CGREEN}#############################################${CEND}"
|
||||
echo -e ' APT FULL-UPGRADE '
|
||||
echo -e "${CGREEN}#############################################${CEND}"
|
||||
$NEED_SUDO apt-get dist-upgrade -y
|
||||
echo -e "${CGREEN}#############################################${CEND}"
|
||||
echo -e ' APT-GET AUTOREMOVE '
|
||||
echo -e "${CGREEN}#############################################${CEND}"
|
||||
$NEED_SUDO apt-get -y --purge autoremove
|
||||
echo -e "${CGREEN}#############################################${CEND}"
|
||||
echo -e ' APT AUTOCLEAN '
|
||||
echo -e "${CGREEN}#############################################${CEND}"
|
||||
$NEED_SUDO apt-get -y autoclean
|
||||
$NEED_SUDO apt-get -y clean
|
||||
## clean packages in deinstall state
|
||||
DEINSTALLED=$($NEED_SUDO dpkg --get-selections | grep deinstall | cut -f1)
|
||||
if [ -n "$DEINSTALLED" ]; then
|
||||
echo -e "${CGREEN}#############################################${CEND}"
|
||||
echo -e ' CLEAN DEINSTALL PACKAGES '
|
||||
echo -e ' APT UPDATE '
|
||||
echo -e "${CGREEN}#############################################${CEND}"
|
||||
$NEED_SUDO dpkg --get-selections | grep deinstall | cut -f1 | xargs dpkg --purge
|
||||
fi
|
||||
if [ -x /usr/bin/docker ]; then
|
||||
$NEED_SUDO apt-get update
|
||||
echo -e "${CGREEN}#############################################${CEND}"
|
||||
echo -e ' DOCKER CLEANUP '
|
||||
echo -e ' APT FULL-UPGRADE '
|
||||
echo -e "${CGREEN}#############################################${CEND}"
|
||||
list_images=$(docker images --filter "dangling=true" -q --no-trunc)
|
||||
list_volumes=$(docker volume ls -qf dangling=true)
|
||||
if [ -n "$list_images" ]; then
|
||||
docker rmi "$list_images"
|
||||
$NEED_SUDO apt-get dist-upgrade -y
|
||||
echo -e "${CGREEN}#############################################${CEND}"
|
||||
echo -e ' APT-GET AUTOREMOVE '
|
||||
echo -e "${CGREEN}#############################################${CEND}"
|
||||
$NEED_SUDO apt-get -y --purge autoremove
|
||||
echo -e "${CGREEN}#############################################${CEND}"
|
||||
echo -e ' APT AUTOCLEAN '
|
||||
echo -e "${CGREEN}#############################################${CEND}"
|
||||
$NEED_SUDO apt-get -y autoclean
|
||||
$NEED_SUDO apt-get -y clean
|
||||
## clean packages in deinstall state
|
||||
DEINSTALLED=$($NEED_SUDO dpkg --get-selections | grep deinstall | cut -f1)
|
||||
if [ -n "$DEINSTALLED" ]; then
|
||||
echo -e "${CGREEN}#############################################${CEND}"
|
||||
echo -e ' CLEAN DEINSTALL PACKAGES '
|
||||
echo -e "${CGREEN}#############################################${CEND}"
|
||||
$NEED_SUDO dpkg --get-selections | grep deinstall | cut -f1 | xargs dpkg --purge
|
||||
fi
|
||||
if [ -n "$list_volumes" ]; then
|
||||
docker volume rm "$list_volumes"
|
||||
if [ -x /usr/bin/docker ]; then
|
||||
echo -e "${CGREEN}#############################################${CEND}"
|
||||
echo -e ' DOCKER CLEANUP '
|
||||
echo -e "${CGREEN}#############################################${CEND}"
|
||||
list_images=$(docker images --filter "dangling=true" -q --no-trunc)
|
||||
list_volumes=$(docker volume ls -qf dangling=true)
|
||||
if [ -n "$list_images" ]; then
|
||||
docker rmi "$list_images"
|
||||
fi
|
||||
if [ -n "$list_volumes" ]; then
|
||||
docker volume rm "$list_volumes"
|
||||
fi
|
||||
fi
|
||||
OLD_LOGS=$($NEED_SUDO find /var/log/ -type f -mtime +30 -iname "*.gz")
|
||||
if [ -n "$OLD_LOGS" ]; then
|
||||
echo -e "${CGREEN}#############################################${CEND}"
|
||||
echo -e ' CLEANUP OLD LOGS '
|
||||
echo -e "${CGREEN}#############################################${CEND}"
|
||||
$NEED_SUDO find /var/log/ -type f -mtime +30 -iname "*.gz" -exec rm '{}' \;
|
||||
fi
|
||||
fi
|
||||
OLD_LOGS=$($NEED_SUDO find /var/log/ -type f -mtime +30 -iname "*.gz")
|
||||
if [ -n "$OLD_LOGS" ]; then
|
||||
echo -e "${CGREEN}#############################################${CEND}"
|
||||
echo -e ' CLEANUP OLD LOGS '
|
||||
echo -e ' EE-BASHRC UPDATE '
|
||||
echo -e "${CGREEN}#############################################${CEND}"
|
||||
$NEED_SUDO find /var/log/ -type f -mtime +30 -iname "*.gz" -exec rm '{}' \;
|
||||
fi
|
||||
echo -e "${CGREEN}#############################################${CEND}"
|
||||
echo -e ' EE-BASHRC UPDATE '
|
||||
echo -e "${CGREEN}#############################################${CEND}"
|
||||
update_git_mybashrc
|
||||
update_git_mybashrc
|
||||
else
|
||||
echo "you need to be root or sudoers to launch the maintenance"
|
||||
fi
|
||||
echo "you need to be root or sudoers to launch the maintenance"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
|
@ -180,10 +180,10 @@ EE_NGINX_COMPILE() {
|
|||
|
||||
EE_SHOW_LOG() {
|
||||
|
||||
{ [ -x /usr/bin/ccze ] && {
|
||||
tail -n 500 "$1" | ccze -A
|
||||
} } || { apt install ccze -y; tail -n 500 "$1" | ccze -A
|
||||
}
|
||||
{ [ -x /usr/bin/ccze ] && {
|
||||
tail -n 500 "$1" | ccze -A
|
||||
} } || { apt install ccze -y; tail -n 500 "$1" | ccze -A
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ CHEAT_CHECK() {
|
|||
{
|
||||
[ -x /usr/local/bin/cht.sh ] && { /usr/local/bin/cht.sh "$@"; }
|
||||
[ -x /usr/bin/cht.sh ] && { /usr/bin/cht.sh "$@"; }
|
||||
} || {
|
||||
} || {
|
||||
curl -s https://cht.sh/:cht.sh >/usr/bin/cht.sh || wget -O /usr/bin/cht.sh https://cht.sh/:cht.sh
|
||||
chmod +x /usr/local/bin/cht.sh
|
||||
/usr/local/bin/cht.sh "$@"
|
||||
|
@ -206,8 +206,28 @@ EE_SHOW_FPM() {
|
|||
|
||||
}
|
||||
|
||||
alias transfer=transfer_vtbox_net
|
||||
MAGENTO_UPGRADE() {
|
||||
|
||||
if [ -x bin/magento ]; then
|
||||
bin/magento maintenance:enable
|
||||
bin/magento cache:flush
|
||||
bin/magento setup:upgrade
|
||||
rm -Rf "./generated/metadata/*" "./generated/code/*" "./var/cache/*" "./var/page_cache/*"
|
||||
bin/magento setup:di:compile
|
||||
/usr/bin/composer dump-autoload -o --apcu
|
||||
rm -Rf "./pub/static/frontend/*" "./pub/static/adminhtml/*" "./var/view_preprocessed/*" "./pub/static/_cache/*" "./pub/static/_requirejs/*"
|
||||
bin/magento setup:static-content:deploy fr_FR
|
||||
bin/magento setup:static-content:deploy en_US --theme="Magento/backend"
|
||||
bin/magento cache:enable
|
||||
bin/magento maintenance:disable
|
||||
else
|
||||
echo "you are not in a magento root folder"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
alias transfer=transfer_vtbox_net
|
||||
alias magento-upgrade=MAGENTO_UPGRADE
|
||||
alias cheat=CHEAT_CHECK
|
||||
#alias wp='/usr/bin/wp --allow-root'
|
||||
|
||||
|
|
40
setup.sh
40
setup.sh
|
@ -1,21 +1,23 @@
|
|||
#!/bin/bash
|
||||
|
||||
# if run as root
|
||||
[ "$(id -u)" = "0" ] && {
|
||||
|
||||
if [ ! -x /usr/bin/git ]; then
|
||||
apt update && apt install -y git
|
||||
fi
|
||||
if [ ! -d $HOME/.ssh ]; then
|
||||
mkdir $HOME/.ssh;
|
||||
fi
|
||||
if [ ! -x /usr/bin/cht.sh ]; then
|
||||
curl https://cht.sh/:cht.sh > /usr/bin/cht.sh || wget -O /usr/bin/cht.sh https://cht.sh/:cht.sh
|
||||
# check if git & curl are installed
|
||||
[ -z "$(command -v git)" ] && { apt-get -y install git >>/dev/null 2>&1; }
|
||||
[ -z "$(command -v curl)" ] && { apt-get -y install curl >>/dev/null 2>&1; }
|
||||
[ ! -d "$HOME/.ssh" ] && { mkdir "$HOME/.ssh"; }
|
||||
|
||||
# install cht.sh if not already installed
|
||||
[ ! -x "$(command -v cht.sh)" ] && {
|
||||
curl -sL https://cht.sh/:cht.sh > /usr/bin/cht.sh || wget -O /usr/bin/cht.sh https://cht.sh/:cht.sh
|
||||
chmod +x /usr/bin/cht.sh
|
||||
fi
|
||||
if [ -f $HOME/.ssh/authorized_keys ]; then
|
||||
}
|
||||
# check for my ssh keys comment
|
||||
[ -f $HOME/.ssh/authorized_keys ] && {
|
||||
check_ecc=$(grep "virtubox.net_ecc" $HOME/.ssh/authorized_keys*)
|
||||
check_rsa=$(grep "virtubox.net_rsa" $HOME/.ssh/authorized_keys*)
|
||||
fi
|
||||
}
|
||||
[ -z "$check_ecc" ] && {
|
||||
echo -e '\n# thomas@virtubox.net\nssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJez+vH3c5kWUqjZ9mjzzW9MTQJmzpgRC8g8vi3ToC9j thomas@virtubox.net_ecc' >>$HOME/.ssh/authorized_keys
|
||||
}
|
||||
|
@ -24,20 +26,22 @@
|
|||
}
|
||||
}
|
||||
|
||||
{ [ ! -d $HOME/.mybashrc ] && {
|
||||
git clone https://git.virtubox.net/virtubox/bashrc.git $HOME/.mybashrc
|
||||
}
|
||||
} || { git -C $HOME/.mybashrc pull origin master
|
||||
# clone mybashrc or update it
|
||||
if [ ! -d $HOME/.mybashrc ]; then
|
||||
git clone https://git.virtubox.net/virtubox/bashrc.git $HOME/.mybashrc
|
||||
else
|
||||
git -C $HOME/.mybashrc pull origin master
|
||||
fi
|
||||
|
||||
}
|
||||
if [ -f $HOME/.bashrc ]; then
|
||||
check_mybashrc=$(grep "mybashrc" $HOME/.bashrc)
|
||||
if [ -z "$check_mybashrc" ]; then
|
||||
echo ". $HOME/.mybashrc/mybashrc" >> $HOME/.bashrc
|
||||
fi
|
||||
else
|
||||
wget -O $HOME/.profile https://git.virtubox.net/virtubox/ubuntu-nginx-web-server/raw/branch/master/var/www/.profile
|
||||
[ ! -f $HOME/.profile ] && {
|
||||
wget -O $HOME/.profile https://git.virtubox.net/virtubox/ubuntu-nginx-web-server/raw/branch/master/var/www/.profile
|
||||
}
|
||||
wget -O $HOME/.bashrc https://git.virtubox.net/virtubox/ubuntu-nginx-web-server/raw/branch/master/var/www/.bashrc
|
||||
echo ". $HOME/.mybashrc/mybashrc" >> $HOME/.bashrc
|
||||
fi
|
||||
source $HOME/.bashrc
|
Loading…
Reference in New Issue