浏览代码

Improve cjdns tools

Bob Mottram 9 年前
父节点
当前提交
95bb0d0693
共有 1 个文件被更改,包括 27 次插入12 次删除
  1. 27
    12
      src/freedombone

+ 27
- 12
src/freedombone 查看文件

2284
     if [ ! -f ~/.bashrc ]; then
2284
     if [ ! -f ~/.bashrc ]; then
2285
         touch ~/.bashrc
2285
         touch ~/.bashrc
2286
     fi
2286
     fi
2287
-    export GOPATH=$HOME/projects/go
2287
+
2288
+    export GOPATH=/home/git/go
2289
+    if [ ! -d /home/git ]; then
2290
+        # add a gogs user account
2291
+        adduser --disabled-login --gecos 'Gogs' git
2292
+
2293
+        # install Go
2294
+        if ! grep -q "export GOPATH=/home/git/go" ~/.bashrc; then
2295
+            echo 'export GOPATH=/home/git/go' >> ~/.bashrc
2296
+            echo 'systemctl set-environment GOPATH=/home/git/go' >> ~/.bashrc
2297
+        fi
2298
+        if [ ! -d $GOPATH ]; then
2299
+            mkdir -p $GOPATH
2300
+        fi
2301
+    fi
2302
+
2288
     if ! grep -q "export GOPATH=" ~/.bashrc; then
2303
     if ! grep -q "export GOPATH=" ~/.bashrc; then
2289
-        echo 'export GOPATH=$HOME/projects/go' >> ~/.bashrc
2304
+        echo "export GOPATH=$GOPATH" >> ~/.bashrc
2290
     fi
2305
     fi
2291
-    if ! grep -q "export PATH=$PATH:$HOME/projects/go/bin" ~/.bashrc; then
2292
-        export PATH=$PATH:$HOME/projects/go/bin
2293
-        echo 'export PATH=$PATH:$HOME/projects/go/bin' >> ~/.bashrc
2306
+    expected_go_path='export PATH=$PATH:'${GOPATH}'/bin'
2307
+    if ! grep -q "$expected_go_path" ~/.bashrc; then
2308
+        export PATH=$PATH:${GOPATH}/bin
2309
+        echo "$expected_go_path" >> ~/.bashrc
2294
     fi
2310
     fi
2295
-    export GOPATH=$HOME/projects/go
2296
-    export PATH=$PATH:$HOME/projects/go/bin
2297
-	CJDCMD_REPO2=$(echo "$CJDCMD_REPO" | sed 's|https://||g')
2311
+    export PATH=$PATH:$GOPATH/bin
2312
+    CJDCMD_REPO2=$(echo "$CJDCMD_REPO" | sed 's|https://||g')
2298
     go get $CJDCMD_REPO2
2313
     go get $CJDCMD_REPO2
2299
-    if [ ! -f $HOME/projects/go/bin/cjdcmd ]; then
2314
+    if [ ! -f $GOPATH/bin/cjdcmd ]; then
2300
         echo $'cjdcmd was not compiled. Check your golang installation'
2315
         echo $'cjdcmd was not compiled. Check your golang installation'
2301
         exit 7439
2316
         exit 7439
2302
     fi
2317
     fi
2303
-    cp $HOME/projects/go/bin/cjdcmd /usr/bin
2318
+    cp $GOPATH/bin/cjdcmd /usr/bin
2304
 
2319
 
2305
     # initialise from the cjdns config
2320
     # initialise from the cjdns config
2306
     /usr/bin/cjdcmd cjdnsadmin -file /etc/cjdns/cjdroute.conf
2321
     /usr/bin/cjdcmd cjdnsadmin -file /etc/cjdns/cjdroute.conf
6650
     if [ ! -d $GOPATH ]; then
6665
     if [ ! -d $GOPATH ]; then
6651
         mkdir -p $GOPATH
6666
         mkdir -p $GOPATH
6652
     fi
6667
     fi
6653
-	GO_PACKAGE_MANAGER_REPO2=$(echo "$GO_PACKAGE_MANAGER_REPO" | sed 's|https://||g')
6668
+    GO_PACKAGE_MANAGER_REPO2=$(echo "$GO_PACKAGE_MANAGER_REPO" | sed 's|https://||g')
6654
     go get -u $GO_PACKAGE_MANAGER_REPO2
6669
     go get -u $GO_PACKAGE_MANAGER_REPO2
6655
     if [ ! "$?" = "0" ]; then
6670
     if [ ! "$?" = "0" ]; then
6656
         exit 479832
6671
         exit 479832
9615
         chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.bashrc
9630
         chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.bashrc
9616
     fi
9631
     fi
9617
 
9632
 
9618
-	IPFS_GO_REPO2=$(echo "$IPFS_GO_REPO" | sed 's|https://||g')
9633
+    IPFS_GO_REPO2=$(echo "$IPFS_GO_REPO" | sed 's|https://||g')
9619
     go get -u ${IPFS_GO_REPO2}/cmd/ipfs
9634
     go get -u ${IPFS_GO_REPO2}/cmd/ipfs
9620
     if [ ! "$?" = "0" ]; then
9635
     if [ ! "$?" = "0" ]; then
9621
         exit 8242
9636
         exit 8242