1
0
mirror of https://shylinux.com/x/ContextOS synced 2025-04-25 16:58:06 +08:00
ContextOS/src/main.sh
2024-03-12 18:32:43 +08:00

39 lines
1.5 KiB
Bash

#!/bin/sh
prepare_package() {
case "$(uname)" in
Darwin) xcode-select --install 2>/dev/null ;;
Linux) if [ `whoami` != "root" ]; then return; fi
if cat /etc/os-release|grep alpine &>/dev/null; then
sed -i 's/dl-cdn.alpinelinux.org/mirrors.tencent.com/g' /etc/apk/repositories && apk update
TZ=Asia/Shanghai; apk add tzdata && cp /usr/share/zoneinfo/${TZ} /etc/localtime && echo ${TZ} > /etc/timezone
return
fi
if cat /etc/os-release|grep "CentOS-8"&>/dev/null; then
minorver=8.5.2111; sed -e "s|^mirrorlist=|#mirrorlist=|g" -e "s|^#baseurl=http://mirror.centos.org/\$contentdir/\$releasever|baseurl=https://mirrors.aliyun.com/centos-vault/$minorver|g" -i.bak /etc/yum.repos.d/CentOS-*.repo && yum update -y
fi
;;
esac
}
main() {
case "$1" in
app) shift # 生产环境
[ -e $ctx_name ] || mkdir $ctx_name; cd $ctx_name
export PS1="\u@\h[\t]\W\$ " PATH="$PWD/bin:$PWD/local/bin:$PWD/usr/local/go/bin:$PATH"
prepare_ice && $PWD/bin/ice.bin forever start "$@"
;;
dev) shift # 开发环境
prepare_package; prepare_system; require miss.sh; [ -f ~/.gitconfig ] || ish_dev_git_prepare
[ -e $ctx_name ] || git config --global "url.$ctx_dev/x/.insteadof" "${ctx_repos%/*}/" && git clone $ctx_repos $ctx_name; cd $ctx_name
source etc/miss.sh && $PWD/bin/ice.bin forever start "$@"
;;
cmd) # 命令环境
ish_sys_dev_init >/dev/null; shift; [ -n "$*" ] && ish_sys_dev_run "$@"
;;
*)
echo "hello world"
;;
esac
}
main "$@"