MCPcopy Create free account
hub / github.com/diyhi/bbs / install

Method install

src/test/java/cms/Init.java:46–187  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

44public class Init {
45
46 @Test
47 public void install() {
48 String userAccount = "admin";//管理员账号
49 String userPassword = "1234567";//管理员密码
50
51
52 String user_dir = System.getProperty("user.dir");
53
54 //默认外部目录
55 String defaultExternalDirectory = "";
56
57 //论坛外部目录
58 Object externalDirectory = YmlUtils.getYmlProperty("application.yml","bbs.externalDirectory");
59 if(externalDirectory != null && !externalDirectory.toString().trim().isEmpty()){//如果已设置了论坛外部目录
60 defaultExternalDirectory = externalDirectory.toString();
61 }else{
62 defaultExternalDirectory = user_dir + File.separator + "target"+ File.separator + "bbs";
63 }
64
65 //生成文件目录
66 Path file = Paths.get(defaultExternalDirectory);
67 if (!Files.exists(file, LinkOption.NOFOLLOW_LINKS)) {//目录不存在
68 try {
69 Files.createDirectories(file);
70 } catch (IOException e) {
71 // TODO Auto-generated catch block
72 e.printStackTrace();
73 }
74 }
75
76 //生成外部文件夹
77 InstallComponent installComponent = new InstallComponent();
78 List<String> folderList = installComponent.folderList();
79 if(folderList != null && !folderList.isEmpty()){
80 for(String folderPath : folderList){
81 //生成文件目录
82 Path path = Paths.get(defaultExternalDirectory+File.separator+ Strings.CS.replace(folderPath, "/", File.separator));
83 if (!Files.exists(path, LinkOption.NOFOLLOW_LINKS)) {//目录不存在
84 try {
85 Files.createDirectories(path);
86 } catch (IOException e) {
87 e.printStackTrace();
88 }
89 }
90 }
91 }
92
93
94 //写入禁止安装系统
95 try {
96 FileUtils.writeStringToFile(new File(defaultExternalDirectory+File.separator+"data"+File.separator+"install"+File.separator+"status.txt"), "1","utf-8",false);
97 } catch (IOException e2) {
98 // TODO Auto-generated catch block
99 e2.printStackTrace();
100 }
101
102 Connection conn = null;
103 ResultSet rs = null;

Callers

nothing calls this directly

Calls 15

getYmlPropertyMethod · 0.95
folderListMethod · 0.95
getConnectionMethod · 0.95
importSQLMethod · 0.95
sha256HexMethod · 0.95
getUUID32Method · 0.95
getPropertyMethod · 0.80
getMethod · 0.80
writeStringToFileMethod · 0.80
nextMethod · 0.80
encodeMethod · 0.80
printlnMethod · 0.80

Tested by

no test coverage detected