-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
387 additions
and
334 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
|
||
_build_mix() { | ||
res=/tmp/res.tar.gz | ||
workspace=/root/workspace/mix | ||
website=/root/apps/nginx/site | ||
for module in $@ ; do | ||
cd $workspace/$module | ||
pnpm install && pnpm build | ||
distPath="" | ||
|
||
case "$module" in | ||
blog) | ||
distPath=$workspace/blog/dist/ | ||
;; | ||
docs) | ||
distPath=$workspace/docs/.vitepress/dist/ | ||
;; | ||
esac | ||
|
||
tar -zcvf $res -C $distPath . | ||
scp -r $res [email protected]:/tmp/ | ||
ssh [email protected] "rm -rf $website/$module.alomerry.com/*; tar -zxvf $res -C $website/$module.alomerry.com/; rm $res" | ||
done | ||
} | ||
|
||
build_docs() { | ||
_build_mix docs | ||
} | ||
|
||
|
||
build_blog() { | ||
_build_mix blog | ||
} | ||
|
||
build() { | ||
for module in $@ ; do | ||
eval "build_$module" | ||
done | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
|
||
install_acme() { | ||
if command -v acme.sh; then | ||
/root/.acme.sh/acme.sh --upgrade | ||
return | ||
fi | ||
|
||
# https://raw.githubusercontent.com/alomerry/mix/master/vm/scripts/acme | ||
wget $INSTALL_PATH/acme.sh -O /tmp/acme.sh | ||
cat /tmp/acme.sh | sh -s -- --install-online | ||
/root/.acme.sh/acme.sh --register-account -m [email protected] | ||
/root/.acme.sh/acme.sh --set-default-ca --server letsencrypt | ||
|
||
wget $ACME_PATH/account.conf -O /root/.acme.sh/account.conf | ||
ansible-vault decrypt --vault-id ~/.ansible/.vault /root/.acme.sh/account.conf | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash | ||
|
||
install_frp_server() { | ||
if [ -f /root/apps/frps/${FRP_VERSION}.version ]; then | ||
return | ||
fi | ||
|
||
wget https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/frp_${FRP_VERSION}_linux_amd64.tar.gz -O /tmp/frp.tar.gz | ||
|
||
rm -rf /root/apps/frps && mkdir /root/apps/frps -p | ||
tar -xf /tmp/frp.tar.gz --strip-components 1 -C /root/apps/frps/ | ||
wget -P /etc/systemd/system/ $FRP_PATH/frps.service | ||
|
||
rm /root/apps/frps/frps.ini | ||
wget -P /root/apps/frps/ $FRP_PATH/frps.ini | ||
ansible-vault decrypt --vault-id ~/.ansible/.vault /root/apps/frps/frps.ini | ||
|
||
touch /root/apps/frps/${FRP_VERSION}.version | ||
rm -rf /root/apps/frps/{frps.tar.gz,frpc,frpc_full.ini,frps_full.ini,frpc.ini} | ||
|
||
systemctl enable frps.service && systemctl stop frps.service | ||
systemctl daemon-reload && systemctl start frps.service | ||
|
||
rm -rf /tmp/frp.tar.gz | ||
} | ||
|
||
install_frp_client() { | ||
if [ -f /root/apps/frpc/${FRP_VERSION}.version ]; then | ||
return | ||
fi | ||
|
||
wget https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/frp_${FRP_VERSION}_linux_amd64.tar.gz -O /tmp/frp.tar.gz | ||
|
||
rm -rf /root/apps/frpc && mkdir /root/apps/frpc -p | ||
tar -xf /tmp/frp.tar.gz --strip-components 1 -C /root/apps/frpc/ | ||
wget -P /etc/systemd/system/ $FRP_PATH/frpc.service | ||
|
||
rm /root/apps/frpc/frpc.ini | ||
wget -P /root/apps/frpc/ $FRP_PATH/frpc.ini | ||
wget -P /root/apps/frpc/ $FRP_PATH/frpc_conf.ini | ||
ansible-vault decrypt --vault-id ~/.ansible/.vault /root/apps/frpc/frpc.ini | ||
|
||
touch /root/apps/frpc/${FRP_VERSION}.version | ||
systemctl enable frpc.service && systemctl stop frpc.service | ||
systemctl daemon-reload && systemctl start frpc.service | ||
|
||
rm -rf /tmp/frp.tar.gz | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
|
||
_load_install() { | ||
wget $SCRIPTS_PATH/app/install/v2ray.sh -O /tmp/install-v2ray.sh | ||
wget $SCRIPTS_PATH/app/install/nginx.sh -O /tmp/install-nginx.sh | ||
wget $SCRIPTS_PATH/app/install/acme.sh -O /tmp/install-acme.sh | ||
wget $SCRIPTS_PATH/app/install/frp.sh -O /tmp/install-frp.sh | ||
wget $SCRIPTS_PATH/app/install/java.sh -O /tmp/install-java.sh | ||
wget $SCRIPTS_PATH/app/install/rust.sh -O /tmp/install-rust.sh | ||
wget $SCRIPTS_PATH/app/install/nvm.sh -O /tmp/install-nvm.sh | ||
source /tmp/install-v2ray.sh | ||
source /tmp/install-nginx.sh | ||
source /tmp/install-acme.sh | ||
source /tmp/install-frp.sh | ||
source /tmp/install-java.sh | ||
source /tmp/install-rust.sh | ||
source /tmp/install-nvm.sh | ||
} | ||
|
||
_install_required() { | ||
if ! command -v ansible > /dev/null 2>&1; then | ||
echo "y" | apt-get ansible | ||
fi | ||
} | ||
|
||
install() { | ||
_load_install | ||
_install_required | ||
|
||
for module in $@ ; do | ||
eval "install_$module" | ||
done | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
install_java() { | ||
# 检验命令是否存在 | ||
if ! command -v javac > /dev/null 2>&1; then | ||
echo "y" | apt-get openjdk-${JAVA_VERSION}-jdk-headless | ||
fi | ||
|
||
if ! command -v javac > /dev/null 2>&1; then | ||
echo "y" | apt-get openjdk-${JAVA_VERSION}-jre-headless | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
install_nginx() { | ||
if ! command -v nginx > /dev/null 2>&1; then | ||
return; | ||
fi | ||
|
||
# https://raw.githubusercontent.com/alomerry/mix/master/vm/scripts/install/nginx.sh | ||
wget $INSTALL_PATH/nginx.sh -O /tmp/nginx.sh | ||
cat /tmp/nginx.sh | sh | ||
|
||
mkdir /root/apps/nginx/{site,cert,conf,logs} -p | ||
mkdir /root/apps/nginx/site/{docs,blog,empty}.alomerry.com -p | ||
touch /root/apps/nginx/cert/{privkey,fullchain}.pem | ||
|
||
wget -P /etc/systemd/system/ $NGINX_PATH/nginx.service | ||
wget -P /etc/nginx/ $NGINX_PATH/nginx.conf | ||
wget -P /root/apps/nginx/conf/ $NGINX_PATH//website.conf | ||
chmod 644 /etc/nginx/nginx.conf | ||
|
||
systemctl daemon-reload | ||
sleep 1 | ||
systemctl force-reload nginx | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
|
||
install_nvm() { | ||
# TODO | ||
if [ ! -d /root/.nvm ]; then | ||
curl -o- ${GIT_RAW_URL}/nvm-sh/nvm/v${NVM_VERSION}/install.sh | bash | ||
source ~/.bashrc | ||
fi | ||
|
||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" | ||
|
||
nvm --version | ||
|
||
for module in $@ ; do | ||
case "$module" in | ||
node) | ||
which npm >/dev/null 2>&1 | ||
if [ $? -ne 0 ]; then | ||
NVM_NODEJS_ORG_MIRROR=https://npmmirror.com/mirrors/node/ nvm install v${NODE_VERSION} | ||
npm config set registry https://registry.npmmirror.com | ||
nvm use v${NODE_VERSION} | ||
fi | ||
;; | ||
pnpm) | ||
which pnpm >/dev/null 2>&1 | ||
if [ $? -ne 0 ]; then | ||
npm install -g pnpm | ||
pnpm config set registry https://registry.npmmirror.com | ||
fi | ||
;; | ||
esac | ||
done | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
install_rust() { | ||
install_java | ||
if command -v cargo > /dev/null 2>&1; then | ||
return; | ||
fi | ||
export RUSTUP_DIST_SERVER="https://rsproxy.cn" | ||
export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup" | ||
|
||
curl --proto '=https' --tlsv1.2 -sSf https://rsproxy.cn/rustup-init.sh | sh | ||
# 此处需要回车 | ||
source "$HOME/.cargo/env" | ||
# https://rsproxy.cn/#getStarted | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
|
||
# https://iitii.github.io/2020/02/04/1/ | ||
install_v2ray_client() { | ||
if command -v v2ray > /dev/null 2>&1; then | ||
return; | ||
fi | ||
|
||
# https://raw.githubusercontent.com/alomerry/mix/master/vm/scripts/install/v2ray.sh | ||
curl -fsSL $V2RAY_PATH/v2ray.sh | bash | ||
|
||
mkdir /usr/local/etc/v2ray/ -p | ||
wget -P /usr/local/etc/v2ray/ $V2RAY_PATH/client.json | ||
wget -P /etc/systemd/system $V2RAY_PATH/v2ray.service | ||
mv /usr/local/etc/v2ray/client.json /usr/local/etc/v2ray/config.json | ||
ansible-vault decrypt --vault-id ~/.ansible/.vault /usr/local/etc/v2ray/config.json | ||
|
||
systemctl enable v2ray | ||
systemctl start v2ray | ||
} | ||
|
||
install_v2ray_server() { | ||
if command -v v2ray > /dev/null 2>&1; then | ||
return; | ||
fi | ||
|
||
# https://raw.githubusercontent.com/alomerry/mix/master/vm/scripts/install/v2ray.sh | ||
curl -fsSL $V2RAY_PATH/v2ray.sh | sh | ||
|
||
wget -P /usr/local/etc/v2ray/ $V2RAY_PATH/server.json | ||
mv /usr/local/etc/v2ray/server.json /usr/local/etc/v2ray/config.json | ||
ansible-vault decrypt --vault-id ~/.ansible/.vault /usr/local/etc/v2ray/config.json | ||
|
||
systemctl enable v2ray | ||
systemctl start v2ray | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
setup_server() { | ||
setup_basic | ||
} | ||
|
||
setup_local() { | ||
setup_basic | ||
} | ||
|
||
setup_ssl_issue() { | ||
/root/.acme.sh/acme.sh --issue --dns dns_cf -d alomerry.com -d *.alomerry.com | ||
set_ssl | ||
} | ||
|
||
set_ssl_renew() { | ||
/root/.acme.sh/acme.sh --renew -d alomerry.com | ||
set_ssl | ||
} | ||
|
||
set_ssl() { | ||
/root/.acme.sh/acme.sh --install-cert -d alomerry.com --key-file /root/apps/nginx/cert/privkey.pem --fullchain-file /root/apps/nginx/cert/fullchain.pem | ||
} | ||
|
||
setup_ssh() { | ||
ssh-copy-id [email protected] | ||
ssh-copy-id [email protected] | ||
} | ||
|
||
setup_basic() { | ||
echo "y" | apt-get install tree aptitude ca-certificates curl gnupg wget cron lsof; | ||
journalctl --vacuum-time=1d && journalctl --vacuum-size=30M | ||
} | ||
|
||
setup() { | ||
for module in $@ ; do | ||
eval "setup_$module" | ||
done | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
# TODO 安装失败如何终止 | ||
apt_install() { | ||
echo "y" | apt-get ${@:1}; | ||
} | ||
|
||
# case "$1" in | ||
# unlock) | ||
# ansible-vault decrypt --vault-id ~/.ansible/.vault /root/workspace/mix/vm/scripts/frp/frpc.ini | ||
# ;; | ||
# lock) | ||
# ansible-vault encrypt --vault-id ~/.ansible/.vault /root/workspace/mix/vm/scripts/frp/frpc.ini | ||
# ;; | ||
# esac |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
main() { | ||
echo "y" | apt-get install socat curl gnupg2 ca-certificates lsb-release ubuntu-keyring; | ||
|
||
curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor | tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null | ||
gpg --dry-run --quiet --no-keyring --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg | ||
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] http://nginx.org/packages/ubuntu $(lsb_release -cs) nginx" | tee /etc/apt/sources.list.d/nginx.list | ||
echo -e "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" | tee /etc/apt/preferences.d/99nginx | ||
apt update && apt install nginx -y | ||
} | ||
|
||
main "$@" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.