1
0
forked from x/ContextOS
ContextOS/src/main.sh
2024-03-14 00:52:31 +08:00

41 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 # 开发环境
require miss.sh; prepare_package; prepare_system; [ -f ~/.gitconfig ] || ish_dev_git_prepare
if ! [ -e $ctx_name ]; then
git config --global "url.$ctx_dev/x/.insteadof" "${ctx_repos%/*}/" && echo && ish_log_debug -g "clone $ctx_repos" && git clone $ctx_repos $ctx_name
fi; 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 "$@"