Mercurial > self-hosted
diff Mercurial/CreathgRepos.sh @ 0:edd512324c03
Add:Mercurial Files
author | Pluto <meokcin@gmail.com> |
---|---|
date | Tue, 03 Sep 2024 16:30:52 +0800 |
parents | |
children | 44d6d3cb28a0 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Mercurial/CreathgRepos.sh Tue Sep 03 16:30:52 2024 +0800 @@ -0,0 +1,42 @@ +#!/bin/bash + +# 提示用户输入仓库名称 +echo "请输入仓库名称(不要中文):" +read repo_name + +# 创建仓库目录 +repo_path="/var/hg/$repo_name" +mkdir -p "$repo_path" + +# 检查目录是否创建成功 +if [ ! -d "$repo_path" ]; then + echo "目录创建失败,请检查权限或磁盘空间。" + exit 1 +fi + +# 初始化Mercurial仓库 +hg init "$repo_path" + +# 更改仓库所有者为www-data +sudo chown -R www-data:www-data "$repo_path" + +# 更改仓库权限为755 +sudo chmod -R 755 "$repo_path" + +# 提示用户输入description和contact的内容 +echo "请输入description的内容:" +read description +echo "请输入contact的内容:" +read contact + +# 构建hgrc文件内容 +hgrc_content="[web] +description = $description +contact = $contact" + +# 写入.hg/hgrc文件 +hgrc_path="$repo_path/.hg/hgrc" +echo "$hgrc_content" | sudo tee "$hgrc_path" > /dev/null + +echo "仓库已成功创建并配置在 $repo_path" +echo "hgrc文件已更新。" \ No newline at end of file