Skip to content

Commit 45ce8c1

Browse files
committed
added sample config and fixed config saving and added config adding (will add warning later)
1 parent d59665d commit 45ce8c1

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

arkr.cpp

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@ int main(int argc, char *argv[]) {
6161
cerr << "This program must be run as root, please su, sudo or doas to run this program" << endl;
6262
return 1;
6363
}
64+
} else if (string(argv[1]) == "configure") {
65+
if (geteuid() != 0) {
66+
cerr << "This program must be run as root, please su, sudo or doas to run this program" << endl;
67+
return 1;
68+
} else {
69+
int confret = system(("cp " + string(argv[2]) + " /etc/arkr.json").c_str());
70+
if (confret != 0) {
71+
cerr << "Failed to copy " << string(argv[2]) << " to /etc/arkr.json" << endl;
72+
return 1;
73+
}
74+
cout << "Copied " << string(argv[2]) << " to /etc/arkr.json" << endl;
75+
return 0;
76+
77+
}
6478
} else if (string(argv[1]) == "about") {
6579
// compile time and date
6680
const char* compileDate = __DATE__;
@@ -99,27 +113,27 @@ int main(int argc, char *argv[]) {
99113
for (int i = 2; i < argc; ++i) {
100114
if (action == 1) {
101115
string packtoadd = argv[i];
102-
if (find(packlist.begin(), packlist.end(), packtoadd) == packlist.end()) {
103-
packlist.push_back(packtoadd);
104-
} else {
105-
cout << "Package " << packtoadd << " is already installed. Reinstalling." << endl;
106-
}
116+
107117
string whatpack = argv[i];
108118
if (whatpack.find('/') != string::npos) {
109119
stringstream ss(whatpack);
110120
getline(ss, group, '/');
111121
getline(ss, packagename, '/');
112-
122+
packtoadd = packagename;
113123
command = "wget -q " + setmirlink + group + "/" + packagename + "/adds";
114124
catcommand = "wget -q --show-progress " + setmirlink + group + "/" + packagename + "/";
115125
} else {
116126
packagename = whatpack;
117127
group = "";
118-
128+
packtoadd = packagename;
119129
command = "wget -q " + setmirlink + packagename + "/adds";
120130
catcommand = "wget -q --show-progress " + setmirlink + packagename + "/";
121131
}
122-
132+
if (find(packlist.begin(), packlist.end(), packtoadd) == packlist.end()) {
133+
134+
} else {
135+
cout << "Package " << packtoadd << " is already installed. Reinstalling." << endl;
136+
}
123137
int ret = system(command.c_str());
124138
if (ret != 0) {
125139
cerr << ("Command to get files failed!\n" + command) << endl;
@@ -183,6 +197,10 @@ int main(int argc, char *argv[]) {
183197
throw runtime_error("Failed to run command: " + chmodcommand);
184198
}
185199
};
200+
if (find(packlist.begin(), packlist.end(), packtoadd) == packlist.end()) {
201+
packlist.push_back(packtoadd);
202+
cout << "Installed " << packtoadd << endl;
203+
}
186204
ss.clear();
187205
ss.seekg(0,ss.beg);
188206
arkrjson["packagever"][packagename] = versioncontent;

arkr.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"packages": [],
3+
"packagever": {}
4+
}

0 commit comments

Comments
 (0)