Merge branch 'main' of https://git.marsway.red/liwei/shellconfig
This commit is contained in:
commit
907c65572e
|
@ -1,4 +1,6 @@
|
||||||
# This is Git's per-user configuration file.
|
# This is Git's per-user configuration file.
|
||||||
|
[http]
|
||||||
|
postBuffer = 524288000
|
||||||
[user]
|
[user]
|
||||||
# Please adapt and uncomment the following lines:
|
# Please adapt and uncomment the following lines:
|
||||||
name = Marsway
|
name = Marsway
|
||||||
|
|
|
@ -7,3 +7,4 @@ install.sh
|
||||||
scripts
|
scripts
|
||||||
README.md
|
README.md
|
||||||
install
|
install
|
||||||
|
linux
|
||||||
|
|
106
Brewfile.txt
106
Brewfile.txt
|
@ -1,106 +0,0 @@
|
||||||
# vim:ft=ruby
|
|
||||||
tap "aws/tap"
|
|
||||||
tap "clementtsang/bottom"
|
|
||||||
tap "federico-terzi/espanso"
|
|
||||||
tap "homebrew/bundle"
|
|
||||||
tap "homebrew/cask"
|
|
||||||
tap "homebrew/core"
|
|
||||||
tap "homebrew/services"
|
|
||||||
tap "jesseduffield/lazygit"
|
|
||||||
tap "khanhas/tap"
|
|
||||||
tap "koekeishiya/formulae"
|
|
||||||
tap "lucassabreu/tap"
|
|
||||||
tap "stripe/stripe-cli"
|
|
||||||
tap "xorpse/formulae"
|
|
||||||
tap "xwmx/taps"
|
|
||||||
brew "amazon-ecs-cli"
|
|
||||||
brew "python@3.9"
|
|
||||||
brew "awscli"
|
|
||||||
brew "bat"
|
|
||||||
brew "glib"
|
|
||||||
brew "pkg-config"
|
|
||||||
brew "dash"
|
|
||||||
brew "exa"
|
|
||||||
brew "fd"
|
|
||||||
brew "fish"
|
|
||||||
brew "fzf"
|
|
||||||
brew "gh"
|
|
||||||
brew "git"
|
|
||||||
brew "git-delta"
|
|
||||||
brew "libusb"
|
|
||||||
brew "gnupg"
|
|
||||||
brew "go"
|
|
||||||
brew "hasura-cli"
|
|
||||||
brew "hyperfine"
|
|
||||||
brew "jq"
|
|
||||||
brew "lazydocker"
|
|
||||||
brew "lf"
|
|
||||||
brew "lsd"
|
|
||||||
brew "luajit", args: ["HEAD"]
|
|
||||||
brew "mackup"
|
|
||||||
brew "mosh"
|
|
||||||
brew "ncdu"
|
|
||||||
brew "neofetch"
|
|
||||||
brew "neovim", args: ["HEAD"]
|
|
||||||
brew "node"
|
|
||||||
brew "node@14"
|
|
||||||
brew "nvm"
|
|
||||||
brew "tmux"
|
|
||||||
brew "overmind"
|
|
||||||
brew "pgcli"
|
|
||||||
brew "postgresql"
|
|
||||||
brew "ripgrep"
|
|
||||||
brew "spotify-tui"
|
|
||||||
brew "starship"
|
|
||||||
brew "switchaudio-osx"
|
|
||||||
brew "tealdeer"
|
|
||||||
brew "terminal-notifier"
|
|
||||||
brew "trash-cli"
|
|
||||||
brew "wallpaper"
|
|
||||||
brew "wget"
|
|
||||||
brew "yarn"
|
|
||||||
brew "zlib"
|
|
||||||
brew "zoxide"
|
|
||||||
brew "aws/tap/aws-sam-cli"
|
|
||||||
brew "clementtsang/bottom/bottom"
|
|
||||||
brew "federico-terzi/espanso/espanso"
|
|
||||||
brew "jesseduffield/lazygit/lazygit"
|
|
||||||
brew "koekeishiya/formulae/skhd"
|
|
||||||
brew "stripe/stripe-cli/stripe"
|
|
||||||
brew "xorpse/formulae/yabai", args: ["HEAD"]
|
|
||||||
brew "tree"
|
|
||||||
brew "repo"
|
|
||||||
cask "1password"
|
|
||||||
cask "alacritty"
|
|
||||||
cask "alfred"
|
|
||||||
cask "appcleaner"
|
|
||||||
cask "balenaetcher"
|
|
||||||
cask "daisydisk"
|
|
||||||
cask "discord"
|
|
||||||
cask "evernote"
|
|
||||||
cask "fantastical"
|
|
||||||
cask "figma"
|
|
||||||
cask "ganache"
|
|
||||||
cask "home-assistant"
|
|
||||||
cask "hyper"
|
|
||||||
cask "imageoptim"
|
|
||||||
cask "ipfs"
|
|
||||||
cask "keycastr"
|
|
||||||
cask "obs"
|
|
||||||
cask "obsidian"
|
|
||||||
cask "plover"
|
|
||||||
cask "postgres"
|
|
||||||
cask "postman"
|
|
||||||
cask "raycast"
|
|
||||||
cask "rocket"
|
|
||||||
cask "sequel-pro"
|
|
||||||
cask "signal"
|
|
||||||
cask "skitch"
|
|
||||||
cask "slack"
|
|
||||||
cask "spacelauncher"
|
|
||||||
cask "spotify"
|
|
||||||
cask "twitch"
|
|
||||||
cask "visual-studio-code"
|
|
||||||
cask "vivaldi"
|
|
||||||
cask "whatsapp"
|
|
||||||
cask "capacities"
|
|
|
@ -0,0 +1 @@
|
||||||
|
crontab ~/.vvconfig/linux/crontab/server.crb
|
|
@ -0,0 +1,3 @@
|
||||||
|
*/5 * * * * flock -xn /tmp/stargate.lock -c '/usr/local/qcloud/stargate/admin/start.sh > /dev/null 2>&1 &'
|
||||||
|
0 0 * * * ~/.vvconfig/linux/scripts/backup_services.sh
|
||||||
|
0 */12 * * * certbot renew --pre-hook "systemctl stop nginx" --post-hook "systemctl start nginx"
|
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/bash
|
||||||
|
pwd=$(realpath $(dirname $0))
|
||||||
|
set -x
|
||||||
|
|
||||||
|
apt install stow
|
||||||
|
cd ~/.vvconfig
|
||||||
|
stow . -t ~
|
||||||
|
|
||||||
|
# Install rclone
|
||||||
|
bash -x $(pwd)/install/install-rclone.sh
|
||||||
|
bash -x $(pwd)/install/install-services-cert.sh
|
||||||
|
bash -x $(pwd)/crontab/install-linux-crontab.sh
|
|
@ -0,0 +1,204 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# error codes
|
||||||
|
# 0 - exited without problems
|
||||||
|
# 1 - parameters not supported were used or some unexpected error occurred
|
||||||
|
# 2 - OS not supported by this script
|
||||||
|
# 3 - installed version of rclone is up to date
|
||||||
|
# 4 - supported unzip tools are not available
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
#when adding a tool to the list make sure to also add its corresponding command further in the script
|
||||||
|
unzip_tools_list=('unzip' '7z' 'busybox')
|
||||||
|
|
||||||
|
usage() { echo "Usage: sudo -v ; curl https://rclone.org/install.sh | sudo bash [-s beta]" 1>&2; exit 1; }
|
||||||
|
|
||||||
|
#check for beta flag
|
||||||
|
if [ -n "$1" ] && [ "$1" != "beta" ]; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$1" ]; then
|
||||||
|
install_beta="beta "
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
#create tmp directory and move to it with macOS compatibility fallback
|
||||||
|
tmp_dir=$(mktemp -d 2>/dev/null || mktemp -d -t 'rclone-install.XXXXXXXXXX')
|
||||||
|
cd "$tmp_dir"
|
||||||
|
|
||||||
|
|
||||||
|
#make sure unzip tool is available and choose one to work with
|
||||||
|
set +e
|
||||||
|
for tool in ${unzip_tools_list[*]}; do
|
||||||
|
trash=$(hash "$tool" 2>>errors)
|
||||||
|
if [ "$?" -eq 0 ]; then
|
||||||
|
unzip_tool="$tool"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# exit if no unzip tools available
|
||||||
|
if [ -z "$unzip_tool" ]; then
|
||||||
|
printf "\nNone of the supported tools for extracting zip archives (${unzip_tools_list[*]}) were found. "
|
||||||
|
printf "Please install one of them and try again.\n\n"
|
||||||
|
exit 4
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Make sure we don't create a root owned .config/rclone directory #2127
|
||||||
|
export XDG_CONFIG_HOME=config
|
||||||
|
|
||||||
|
#check installed version of rclone to determine if update is necessary
|
||||||
|
version=$(rclone --version 2>>errors | head -n 1)
|
||||||
|
if [ -z "$install_beta" ]; then
|
||||||
|
current_version=$(curl -fsS https://downloads.rclone.org/version.txt)
|
||||||
|
else
|
||||||
|
current_version=$(curl -fsS https://beta.rclone.org/version.txt)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$version" = "$current_version" ]; then
|
||||||
|
printf "\nThe latest ${install_beta}version of rclone ${version} is already installed.\n\n"
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
#detect the platform
|
||||||
|
OS="$(uname)"
|
||||||
|
case $OS in
|
||||||
|
Linux)
|
||||||
|
OS='linux'
|
||||||
|
;;
|
||||||
|
FreeBSD)
|
||||||
|
OS='freebsd'
|
||||||
|
;;
|
||||||
|
NetBSD)
|
||||||
|
OS='netbsd'
|
||||||
|
;;
|
||||||
|
OpenBSD)
|
||||||
|
OS='openbsd'
|
||||||
|
;;
|
||||||
|
Darwin)
|
||||||
|
OS='osx'
|
||||||
|
binTgtDir=/usr/local/bin
|
||||||
|
man1TgtDir=/usr/local/share/man/man1
|
||||||
|
;;
|
||||||
|
SunOS)
|
||||||
|
OS='solaris'
|
||||||
|
echo 'OS not supported'
|
||||||
|
exit 2
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo 'OS not supported'
|
||||||
|
exit 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
OS_type="$(uname -m)"
|
||||||
|
case "$OS_type" in
|
||||||
|
x86_64|amd64)
|
||||||
|
OS_type='amd64'
|
||||||
|
;;
|
||||||
|
i?86|x86)
|
||||||
|
OS_type='386'
|
||||||
|
;;
|
||||||
|
aarch64|arm64)
|
||||||
|
OS_type='arm64'
|
||||||
|
;;
|
||||||
|
armv7*)
|
||||||
|
OS_type='arm-v7'
|
||||||
|
;;
|
||||||
|
armv6*)
|
||||||
|
OS_type='arm-v6'
|
||||||
|
;;
|
||||||
|
arm*)
|
||||||
|
OS_type='arm'
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo 'OS type not supported'
|
||||||
|
exit 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
#download and unzip
|
||||||
|
if [ -z "$install_beta" ]; then
|
||||||
|
download_link="https://downloads.rclone.org/rclone-current-${OS}-${OS_type}.zip"
|
||||||
|
rclone_zip="rclone-current-${OS}-${OS_type}.zip"
|
||||||
|
else
|
||||||
|
download_link="https://beta.rclone.org/rclone-beta-latest-${OS}-${OS_type}.zip"
|
||||||
|
rclone_zip="rclone-beta-latest-${OS}-${OS_type}.zip"
|
||||||
|
fi
|
||||||
|
|
||||||
|
curl -OfsS "$download_link"
|
||||||
|
unzip_dir="tmp_unzip_dir_for_rclone"
|
||||||
|
# there should be an entry in this switch for each element of unzip_tools_list
|
||||||
|
case "$unzip_tool" in
|
||||||
|
'unzip')
|
||||||
|
unzip -a "$rclone_zip" -d "$unzip_dir"
|
||||||
|
;;
|
||||||
|
'7z')
|
||||||
|
7z x "$rclone_zip" "-o$unzip_dir"
|
||||||
|
;;
|
||||||
|
'busybox')
|
||||||
|
mkdir -p "$unzip_dir"
|
||||||
|
busybox unzip "$rclone_zip" -d "$unzip_dir"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
cd $unzip_dir/*
|
||||||
|
|
||||||
|
#mounting rclone to environment
|
||||||
|
|
||||||
|
case "$OS" in
|
||||||
|
'linux')
|
||||||
|
#binary
|
||||||
|
cp rclone /usr/bin/rclone.new
|
||||||
|
chmod 755 /usr/bin/rclone.new
|
||||||
|
chown root:root /usr/bin/rclone.new
|
||||||
|
mv /usr/bin/rclone.new /usr/bin/rclone
|
||||||
|
#manual
|
||||||
|
if ! [ -x "$(command -v mandb)" ]; then
|
||||||
|
echo 'mandb not found. The rclone man docs will not be installed.'
|
||||||
|
else
|
||||||
|
mkdir -p /usr/local/share/man/man1
|
||||||
|
cp rclone.1 /usr/local/share/man/man1/
|
||||||
|
mandb
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
'freebsd'|'openbsd'|'netbsd')
|
||||||
|
#binary
|
||||||
|
cp rclone /usr/bin/rclone.new
|
||||||
|
chown root:wheel /usr/bin/rclone.new
|
||||||
|
mv /usr/bin/rclone.new /usr/bin/rclone
|
||||||
|
#manual
|
||||||
|
mkdir -p /usr/local/man/man1
|
||||||
|
cp rclone.1 /usr/local/man/man1/
|
||||||
|
makewhatis
|
||||||
|
;;
|
||||||
|
'osx')
|
||||||
|
#binary
|
||||||
|
mkdir -m 0555 -p ${binTgtDir}
|
||||||
|
cp rclone ${binTgtDir}/rclone.new
|
||||||
|
mv ${binTgtDir}/rclone.new ${binTgtDir}/rclone
|
||||||
|
chmod a=x ${binTgtDir}/rclone
|
||||||
|
#manual
|
||||||
|
mkdir -m 0555 -p ${man1TgtDir}
|
||||||
|
cp rclone.1 ${man1TgtDir}
|
||||||
|
chmod a=r ${man1TgtDir}/rclone.1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo 'OS not supported'
|
||||||
|
exit 2
|
||||||
|
esac
|
||||||
|
|
||||||
|
#update version variable post install
|
||||||
|
version=$(rclone --version 2>>errors | head -n 1)
|
||||||
|
|
||||||
|
#cleanup
|
||||||
|
rm -rf "$tmp_dir"
|
||||||
|
|
||||||
|
printf "\n${version} has successfully installed."
|
||||||
|
printf '\nNow run "rclone config" for setup. Check https://rclone.org/docs/ for more details.\n\n'
|
||||||
|
exit 0
|
|
@ -0,0 +1,9 @@
|
||||||
|
#!/bin/bash
|
||||||
|
sudo apt-get -y install certbot nginx
|
||||||
|
sudo systemctl stop nginx
|
||||||
|
certbot certonly --standalone -d git.marsway.red
|
||||||
|
certbot certonly --standalone -d star.marsway.red
|
||||||
|
certbot certonly --standalone -d www.marsway.red
|
||||||
|
certbot certonly --standalone -d lm.marsway.red
|
||||||
|
certbot certonly --standalone -d vpn.marsway.red
|
||||||
|
sudo systemctl start nginx
|
|
@ -0,0 +1,18 @@
|
||||||
|
#!/bin/bash
|
||||||
|
today=$(date +%Y%m%d)
|
||||||
|
basedir=/root/backup/
|
||||||
|
log=/root/backup/$today.log
|
||||||
|
|
||||||
|
echo "Starting backup..." | tee $log
|
||||||
|
echo "Zip $basedir/forgejo/$today.zip..." | tee $log
|
||||||
|
zip -r $basedir/forgejo/$today.zip /opt/forgejo/ > /dev/null
|
||||||
|
zip -r $basedir/linkding/$today.zip /opt/linkding/ > /dev/null
|
||||||
|
rm -rf $basedir/nginx/*.conf && cp -r /etc/nginx/conf.d/* $basedir/nginx > /dev/null
|
||||||
|
|
||||||
|
echo "Deleting old backups..." | tee $log
|
||||||
|
find /root/backup -name "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].zip" -mtime +6 -ls | tee $log
|
||||||
|
find /root/backup -name "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].zip" -mtime +6 -delete
|
||||||
|
|
||||||
|
echo "Syncing to google drive..." | tee $log
|
||||||
|
rclone sync /root/backup gd:Backups/server
|
||||||
|
rclone sync /root/backup od:Backups/server
|
Loading…
Reference in New Issue