浏览代码

Move commit function to separate script

Bob Mottram 8 年前
父节点
当前提交
229df46f2a
没有帐户链接到提交者的电子邮件
共有 2 个文件被更改,包括 114 次插入94 次删除
  1. 0
    94
      src/freedombone
  2. 114
    0
      src/freedombone-utils-git

+ 0
- 94
src/freedombone 查看文件

@@ -1578,100 +1578,6 @@ function rss_reader_modifications {
1578 1578
 	chmod a+x $RSS_READER_PATH
1579 1579
 }
1580 1580
 
1581
-function set_repo_commit {
1582
-	repo_dir=$1
1583
-	repo_commit_name=$2
1584
-	repo_commit=$3
1585
-	repo_url=$4
1586
-	if [ -d $repo_dir ]; then
1587
-		if grep -q "$repo_commit_name" $COMPLETION_FILE; then
1588
-			CURRENT_REPO_COMMIT=$(grep "$repo_commit_name" $COMPLETION_FILE | awk -F ':' '{print $2}')
1589
-			if [[ "$CURRENT_REPO_COMMIT" != "$repo_commit" ]]; then
1590
-				cd $repo_dir
1591
-				git_pull $repo_url $repo_commit
1592
-
1593
-				# application specific stuff after updating the repo
1594
-				if [[ $repo_dir == *"www"* ]]; then
1595
-					chown -R www-data:www-data $repo_dir
1596
-				fi
1597
-				if [[ $repo_dir == *"cjdns" ]]; then
1598
-					./do
1599
-				fi
1600
-				if [[ $repo_dir == *"tlsdate" ]]; then
1601
-					cd $INSTALL_DIR/tlsdate
1602
-					make clean
1603
-					./configure
1604
-					if [ ! "$?" = "0" ]; then
1605
-						echo $'Failed to configure tlsdate'
1606
-						exit 727824
1607
-					fi
1608
-					make
1609
-					if [ ! "$?" = "0" ]; then
1610
-						echo $'Failed to build tlsdate'
1611
-						exit 728752
1612
-					fi
1613
-					make install
1614
-				fi
1615
-				if [[ $repo_dir == *"gpgit" ]]; then
1616
-					cp gpgit.pl /usr/bin/gpgit.pl
1617
-				fi
1618
-				if [[ $repo_dir == *"cleanup-maildir" ]]; then
1619
-					cp $INSTALL_DIR/cleanup-maildir/cleanup-maildir /usr/bin
1620
-				fi
1621
-				if [[ $repo_dir == *"nginx_ensite" ]]; then
1622
-					make install
1623
-				fi
1624
-				if [[ $repo_dir == *"gogs" ]]; then
1625
-					git checkout master
1626
-					go get -u ./...
1627
-					if [ ! "$?" = "0" ]; then
1628
-						echo $'Failed to get gogs'
1629
-						exit 52792
1630
-					fi
1631
-					git checkout $repo_commit
1632
-					go build
1633
-					if [ ! "$?" = "0" ]; then
1634
-						echo $'Failed to build gogs'
1635
-						exit 36226
1636
-					fi
1637
-					systemctl restart gogs
1638
-				fi
1639
-				if [[ $repo_dir == *"toxcore" ]]; then
1640
-					sed -i 's|ExecStart=.*|ExecStart=/usr/local/bin/tox-bootstrapd --config /etc/tox-bootstrapd.conf|g' $rootdir/etc/systemd/system/tox-bootstrapd.service
1641
-					autoreconf -i
1642
-					./configure --enable-daemon
1643
-					make
1644
-					make install
1645
-					systemctl daemon-reload
1646
-					systemctl restart tox-bootstrapd.service
1647
-				fi
1648
-				if [[ $repo_dir == *"toxic" ]]; then
1649
-					make
1650
-					make install
1651
-				fi
1652
-				if [[ $repo_dir == $RSS_READER_PATH ]]; then
1653
-					rss_reader_modifications
1654
-				fi
1655
-				if [[ $repo_dir == *"inadyn" ]]; then
1656
-					./configure
1657
-					USE_OPENSSL=1 make
1658
-					make install
1659
-					systemctl restart inadyn
1660
-				fi
1661
-				if [[ $repo_dir == *"ipfs" ]]; then
1662
-					chown -R git:git /home/git
1663
-					systemctl restart ipfs
1664
-					systemctl daemon-reload
1665
-				fi
1666
-
1667
-				sed -i "s/${repo_commit_name}.*/${repo_commit_name}:$repo_commit/g" $COMPLETION_FILE
1668
-			fi
1669
-		else
1670
-			echo "${repo_commit_name}:${repo_commit}" >> $COMPLETION_FILE
1671
-		fi
1672
-	fi
1673
-}
1674
-
1675 1581
 function wait_for_onion_service {
1676 1582
 	onion_service_name="$1"
1677 1583
 

+ 114
- 0
src/freedombone-utils-git 查看文件

@@ -88,4 +88,118 @@ function git_pull {
88 88
 	fi
89 89
 }
90 90
 
91
+# This might be replaced in future with a separate rss reader script
92
+function rss_reader_modifications {
93
+	# modify the rss reader to use a socks5 proxy rather than a http proxy
94
+	if [ ! -d $RSS_READER_PATH ]; then
95
+		return
96
+	fi
97
+
98
+	# ensure that socks5 proxy is used
99
+	if ! grep -q "CURLOPT_PROXYTYPE" $RSS_READER_PATH/plugins/af_unburn/init.php; then
100
+		sed -i '/curl_setopt($ch, CURLOPT_PROXY, _CURL_HTTP_PROXY);/a \\t\t\t\t\tcurl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);' $RSS_READER_PATH/plugins/af_unburn/init.php
101
+	fi
102
+	if ! grep -q "CURLOPT_PROXYTYPE" $RSS_READER_PATH/include/functions.php; then
103
+		sed -i '/curl_setopt($ch, CURLOPT_PROXY, _CURL_HTTP_PROXY);/a \\t\t\t\tcurl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);' $RSS_READER_PATH/include/functions.php
104
+	fi
105
+	chown -R www-data:www-data $RSS_READER_PATH
106
+	chmod a+x $RSS_READER_PATH
107
+}
108
+
109
+# This ensures that a given repo is on a given commit
110
+# If it isn't then it attempts to upgrade
111
+function set_repo_commit {
112
+	repo_dir=$1
113
+	repo_commit_name=$2
114
+	repo_commit=$3
115
+	repo_url=$4
116
+	if [ -d $repo_dir ]; then
117
+		if grep -q "$repo_commit_name" $COMPLETION_FILE; then
118
+			CURRENT_REPO_COMMIT=$(grep "$repo_commit_name" $COMPLETION_FILE | awk -F ':' '{print $2}')
119
+			if [[ "$CURRENT_REPO_COMMIT" != "$repo_commit" ]]; then
120
+				cd $repo_dir
121
+				git_pull $repo_url $repo_commit
122
+
123
+				# application specific stuff after updating the repo
124
+				if [[ $repo_dir == *"www"* ]]; then
125
+					chown -R www-data:www-data $repo_dir
126
+				fi
127
+				if [[ $repo_dir == *"cjdns" ]]; then
128
+					./do
129
+				fi
130
+				if [[ $repo_dir == *"tlsdate" ]]; then
131
+					cd $INSTALL_DIR/tlsdate
132
+					make clean
133
+					./configure
134
+					if [ ! "$?" = "0" ]; then
135
+						echo $'Failed to configure tlsdate'
136
+						exit 727824
137
+					fi
138
+					make
139
+					if [ ! "$?" = "0" ]; then
140
+						echo $'Failed to build tlsdate'
141
+						exit 728752
142
+					fi
143
+					make install
144
+				fi
145
+				if [[ $repo_dir == *"gpgit" ]]; then
146
+					cp gpgit.pl /usr/bin/gpgit.pl
147
+				fi
148
+				if [[ $repo_dir == *"cleanup-maildir" ]]; then
149
+					cp $INSTALL_DIR/cleanup-maildir/cleanup-maildir /usr/bin
150
+				fi
151
+				if [[ $repo_dir == *"nginx_ensite" ]]; then
152
+					make install
153
+				fi
154
+				if [[ $repo_dir == *"gogs" ]]; then
155
+					git checkout master
156
+					go get -u ./...
157
+					if [ ! "$?" = "0" ]; then
158
+						echo $'Failed to get gogs'
159
+						exit 52792
160
+					fi
161
+					git checkout $repo_commit
162
+					go build
163
+					if [ ! "$?" = "0" ]; then
164
+						echo $'Failed to build gogs'
165
+						exit 36226
166
+					fi
167
+					systemctl restart gogs
168
+				fi
169
+				if [[ $repo_dir == *"toxcore" ]]; then
170
+					sed -i 's|ExecStart=.*|ExecStart=/usr/local/bin/tox-bootstrapd --config /etc/tox-bootstrapd.conf|g' $rootdir/etc/systemd/system/tox-bootstrapd.service
171
+					autoreconf -i
172
+					./configure --enable-daemon
173
+					make
174
+					make install
175
+					systemctl daemon-reload
176
+					systemctl restart tox-bootstrapd.service
177
+				fi
178
+				if [[ $repo_dir == *"toxic" ]]; then
179
+					make
180
+					make install
181
+				fi
182
+				if [[ $repo_dir == $RSS_READER_PATH ]]; then
183
+					rss_reader_modifications
184
+				fi
185
+				if [[ $repo_dir == *"inadyn" ]]; then
186
+					./configure
187
+					USE_OPENSSL=1 make
188
+					make install
189
+					systemctl restart inadyn
190
+				fi
191
+				if [[ $repo_dir == *"ipfs" ]]; then
192
+					chown -R git:git /home/git
193
+					systemctl restart ipfs
194
+					systemctl daemon-reload
195
+				fi
196
+
197
+				sed -i "s/${repo_commit_name}.*/${repo_commit_name}:$repo_commit/g" $COMPLETION_FILE
198
+			fi
199
+		else
200
+			echo "${repo_commit_name}:${repo_commit}" >> $COMPLETION_FILE
201
+		fi
202
+	fi
203
+}
204
+
91 205
 # NOTE: deliberately no exit 0