Skip to content
This repository has been archived by the owner on Nov 12, 2023. It is now read-only.

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
Signed-off-by: BurningPho3nix <pr@burningpho3nix.xyz>
  • Loading branch information
BurningPho3nix authored Nov 7, 2023
1 parent 28c4ac3 commit 641b96a
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 22 deletions.
20 changes: 14 additions & 6 deletions starter/setup-tool-beta.1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.TH Setup Tool "Version Beta" "User Manual"
.TH Setup Tool "Version: Beta" "User Manual"

.SH NAME
setup-tool \- Setup-Tool
setup-tool-beta \- Setup Tool Beta

.SH DESCRIPTION
This program is made to make setting up different things, like codecs and repos, easier on Fedora.
Expand All @@ -16,15 +16,23 @@ Options of this program are following:
- System upgrade
- Reboot

Please remember that this program is not part of the Fedora Project and is maintained by a third-party person.
Please remember that this program is not part of the Fedora Project and is maintained by a third-party community.

.SH OPTIONS
.TP
.B setup-tool-beta.conf
current config options:

tp_notice = True/False | True = enables third-party notice // False = disables third-party notice
| default is True, but will be changed to False if you accept the notice in the program

.SH USAGE
To use Setup-Tool, open a terminal and run the following command:
To use Setup Tool (beta), open a terminal and run the following command:

.BR setup-tool
.BR setup-tool-beta

.SH NOTES
This project is maintained by a third-party developer and not part of the Fedora Project.
This project is maintained by a third-party community and not part of the Fedora Project.

.SH AUTHOR
Setup Tooling Project <pr_st@burningpho3nix.xyz>
Expand Down
67 changes: 51 additions & 16 deletions starter/setup-tool-beta.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
#include <stdlib.h>
#include <unistd.h>
#include <stddef.h>
#include <string.h>

#define PROGRAMS_PATH "/usr/bin/"

#define CONFIG_FILE "/etc/setup-tool-beta.conf"

int checkProgramExists(const char* programName) {
char fullPath[100];
sprintf(fullPath, "%s%s", PROGRAMS_PATH, programName);
Expand All @@ -16,6 +19,35 @@ int checkProgramExists(const char* programName) {
}
}

int shouldShowNotice() {
FILE *file = fopen(CONFIG_FILE, "r");
if (file != NULL) {
char line[50];
if (fgets(line, sizeof(line), file) != NULL) {
fclose(file);
if (strstr(line, "tp-notice = ") != NULL) {
char* response = strchr(line, '=') + 2;
response[strcspn(response, "\n")] = '\0'; // Remove newline character
if (strcasecmp(response, "True") == 0) {
return 1; // Show the notice
} else if (strcasecmp(response, "False") == 0) {
return 0; // Don't show the notice
}
}
}
}
return 1; // Show the notice by default
}

void saveUserResponse(char response) {
const char* configResponse = (response == 'Y' || response == 'y') ? "False" : "True";
FILE *file = fopen(CONFIG_FILE, "w");
if (file != NULL) {
fprintf(file, "tp-notice = %s\n", configResponse);
fclose(file);
}
}

int main() {
const char* programs[] = {"setup-tool-cli-beta", "setup-tool-tui-beta", "setup-tool-gui-beta"};
int numPrograms = sizeof(programs) / sizeof(programs[0]);
Expand All @@ -35,22 +67,25 @@ int main() {
return 0;
}

// Ask the user for confirmation
char confirm[2];
int validInput = 0;

while (!validInput) {
printf("This program might pull software from third party repositories,\n");
printf("if you enable these repositories through this program or through other means.\n");
printf("Do you accept this? (Y/n): ");
fgets(confirm, sizeof(confirm), stdin);
if (confirm[0] == 'Y' || confirm[0] == 'y' || confirm[0] == '\n') {
validInput = 1;
} else if (confirm[0] == 'N' || confirm[0] == 'n') {
printf("Exiting the program.\n");
return 0;
} else {
printf("Invalid input. Please enter Y/y or Enter to confirm or N/n to exit.\n");
if (shouldShowNotice()) {
char confirm[2];
int validInput = 0;

while (!validInput) {
printf("This program might pull software from third party repositories,\n");
printf("if you enable these repositories through this program or through other means.\n");
printf("Do you accept this? (Y/n): ");
fgets(confirm, sizeof(confirm), stdin);
if (confirm[0] == 'Y' || confirm[0] == 'y' || confirm[0] == '\n') {
validInput = 1;
saveUserResponse('Y'); // Save user's "Y" response as 'False'
} else if (confirm[0] == 'N' || confirm[0] == 'n') {
printf("Exiting the program.\n");
saveUserResponse('N'); // Save user's "N" response as 'True'
return 0;
} else {
printf("Invalid input. Please enter Y/y or Enter to confirm or N/n to exit.\n");
}
}
}

Expand Down
1 change: 1 addition & 0 deletions starter/setup-tool-beta.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tp_notice = True

0 comments on commit 641b96a

Please sign in to comment.