comparison Mercurial/re.sh @ 2:c8c80b5286b1

add:Mercurial re.sh 新版本自动创建仓库脚本
author Pluto <meokcin@gmail.com>
date Tue, 03 Sep 2024 17:01:40 +0800
parents
children
comparison
equal deleted inserted replaced
1:44d6d3cb28a0 2:c8c80b5286b1
1 #!/bin/bash
2
3 # 提示用户输入仓库名称
4 echo "请输入仓库名称(不要使用中文):"
5 read repo_name
6
7 # 创建仓库目录
8 repo_path="/var/hg/$repo_name"
9 mkdir -p "$repo_path"
10
11 # 检查目录是否创建成功
12 if [ ! -d "$repo_path" ]; then
13 echo "目录创建失败,请检查权限或磁盘空间。"
14 exit 1
15 fi
16
17 # 初始化Mercurial仓库
18 hg init "$repo_path"
19
20 # 提示用户输入description和contact的内容
21 echo "请输入description的内容:"
22 read description
23 echo "请输入contact的内容:"
24 read contact
25
26 # 构建hgrc文件内容
27 hgrc_content="# example repository config (see 'hg help config' for more info)
28 [paths]
29 default = https://hg.nnsui.com/$repo_name/
30
31 # path aliases to other clones of this repo in URLs or filesystem paths
32 # (see 'hg help config.paths' for more info)
33 #
34 # default:pushurl = ssh://jdoe@example.net/hg/jdoes-fork
35 # my-fork = ssh://jdoe@example.net/hg/jdoes-fork
36 # my-clone = /home/jdoe/jdoes-clone
37
38 [ui]
39 # name and email (local to this repository, optional), e.g.
40 # username = Jane Doe <jdoe@example.com>
41
42 [web]
43 encoding = UTF-8
44 description = $description
45 contact = $contact"
46
47 # 写入.hg/hgrc文件
48 hgrc_path="$repo_path/.hg/hgrc"
49 echo "$hgrc_content" | sudo tee "$hgrc_path" > /dev/null
50
51 # 更改仓库所有者为www-data
52 sudo chown -R www-data:www-data "$repo_path"
53
54 # 更改仓库权限为755
55 sudo chmod -R 755 "$repo_path"
56
57 echo "仓库已成功创建并配置在 $repo_path"
58 echo "hgrc文件已更新。"
59 echo "仓库所有者和权限已更改。"
备案号:苏ICP备2024087954号-2 | 渝公网安备50010402001513