mirror of
https://github.com/PGYER/codefever.git
synced 2026-06-02 15:13:41 +08:00
Merge pull request #31 from PGYER/dev/master
feat(Install Script): add script for remove unit test data (github issue #30)
This commit is contained in:
@@ -223,6 +223,13 @@ cd /data/www/codefever-community/misc
|
||||
sh ./create_db.sh
|
||||
```
|
||||
|
||||
如果你不需要对 CodeFever 进行代码上的修改, 或者将来不计划运行单元测试, 可以删除测试数据
|
||||
|
||||
```shell
|
||||
cd /data/www/codefever-community/misc
|
||||
sh ./remove_test_data.sh
|
||||
```
|
||||
|
||||
为服务开启 `chkconfig` 以开机自动运行
|
||||
|
||||
```shell
|
||||
|
||||
@@ -73,3 +73,4 @@ echo '1. You shuold edit file </data/www/codefever-community/env.yaml: mysql/*>
|
||||
echo '2. You shuold edit file </data/www/codefever-community/env.yaml: session/*> to finish cookie settings.'
|
||||
echo '3. You shuold edit file </data/www/codefever-community/env.yaml: gateway/token> to finish git gateway security settings.'
|
||||
echo '4. Run sh ./create_db.sh after change env.yaml.'
|
||||
echo '5. Run sh ./remove_test_data.sh if you DO NOT need to run unit test.'
|
||||
|
||||
34
misc/remove_test_data.sh
Normal file
34
misc/remove_test_data.sh
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
if [ $UID -ne 0 ]; then
|
||||
echo 'run as root please'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DB_HOST=`cat ../env.yaml | grep host: | awk -F: '{ print $2 }' | sed 's/^\s*//'`
|
||||
DB_PORT=`cat ../env.yaml | grep port: | awk -F: '{ print $2 }' | sed 's/^\s*//'`
|
||||
DB_USER=`cat ../env.yaml | grep username: | awk -F: '{ print $2 }' | sed 's/^\s*//'`
|
||||
DB_PASS=`cat ../env.yaml | grep password: | awk -F: '{ print $2 }' | sed 's/^\s*//'`
|
||||
DB_NAME=`cat ../env.yaml | grep db: | awk -F: '{ print $2 }' | sed 's/^\s*//'`
|
||||
|
||||
|
||||
mysql -h"$DB_HOST" -P"$DB_PORT" -u"$DB_USER" -p"$DB_PASS" -D"$DB_NAME" -e"DELETE FROM cc_users WHERE u_key = '26c20714af8bc20aa85be657a5170e71';";
|
||||
mysql -h"$DB_HOST" -P"$DB_PORT" -u"$DB_USER" -p"$DB_PASS" -D"$DB_NAME" -e"DELETE FROM cc_users WHERE u_key = 'f4a9c54adef17599d4f709a1167f0fcd';";
|
||||
|
||||
mysql -h"$DB_HOST" -P"$DB_PORT" -u"$DB_USER" -p"$DB_PASS" -D"$DB_NAME" -e"DELETE FROM cc_ssh_keys WHERE u_key = 'f4a9c54adef17599d4f709a1167f0fcd';";
|
||||
|
||||
echo 'Test User Data Removed!'
|
||||
|
||||
mysql -h"$DB_HOST" -P"$DB_PORT" -u"$DB_USER" -p"$DB_PASS" -D"$DB_NAME" -e"DELETE FROM cc_repositories WHERE r_key = '2f941aef39bc8a048da55dd28c678655';";
|
||||
|
||||
echo 'Test Repository Data Removed!'
|
||||
|
||||
mysql -h"$DB_HOST" -P"$DB_PORT" -u"$DB_USER" -p"$DB_PASS" -D"$DB_NAME" -e"DELETE FROM cc_groups WHERE g_key = 'e6508c1a66e86f697c96bdffb30c1ae3';";
|
||||
|
||||
echo 'Test Group Data Removed!'
|
||||
|
||||
rm -rf ../git-storage/7b56eed88bda864c6e5ae1540549f8ab
|
||||
|
||||
echo 'Test Repository Removed'
|
||||
|
||||
echo 'Done!'
|
||||
echo 'All Test Data Removed !'
|
||||
Reference in New Issue
Block a user