unixwz0r

installer.c

Nov 8th, 2015
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 5.43 KB | None | 0 0
  1. /*
  2.  * BSDBOX installer Program
  3.  * The BSDBox Project By: Gary & Vincent
  4.  * Nov. 2015
  5.  *
  6. */    
  7. #include <ncurses.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <sys/utsname.h>
  11. #include <unistd.h>
  12. #include <string.h>
  13. #include <errno.h>
  14. #include <sys/wait.h>
  15. #include <sys/sysctl.h>
  16. #define RED     "\x1b[31m" // Colours for the logo to make it pretty!
  17. #define GREEN   "\x1b[32m"
  18. #define BLUE    "\x1b[34m"
  19. #define RESET   "\x1b[0m"
  20.  
  21. /* BSDBOX logo created by me, I use block characters */
  22. void print_logo(){
  23.  
  24. printf(RED"╔═══════════════════════════════════════════════════════════════════╗\n");
  25. printf(RED"║ ▄▄▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄    ▄▄▄▄ "RED"║\n");
  26. printf(RED"║ ▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄   ▄▄    ▄▄  "RED" ║\n");
  27. printf(RED"║  ▄▄   ▄▄▄ ▄▄        ▄▄▄    ▄▄▄▄  ▄▄   ▄▄▄ ▄▄▄    ▄▄▄     ▄  ▄    "RED" ║\n");
  28. printf(RED"║  ▄▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄▄ ▄▄▄    ▄▄▄▄  ▄▄▄▄▄▄▄  ▄▄▄    ▄▄▄      ▄▄     "RED" ║\n");
  29. printf(RED"║  ▄▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄▄ ▄▄▄    ▄▄▄▄  ▄▄▄▄▄▄▄  ▄▄▄    ▄▄▄      ▄▄     "RED" ║\n");
  30. printf(RED"║  ▄▄   ▄▄▄        ▄▄ ▄▄▄    ▄▄▄▄  ▄▄   ▄▄▄ ▄▄▄    ▄▄▄     ▄  ▄    "RED" ║\n");
  31. printf(RED"║ ▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄   ▄▄    ▄▄  "RED" ║\n");
  32. printf(RED"║ ▄▄▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄    ▄▄▄▄"RED" ║\n");
  33. printf(RED"║"GREEN"                                                      Install v0.1"RED" ║\n");
  34. printf(RED"╚═══════════════════════════════════════════════════════════════════╝"RESET"\n");
  35. }
  36.  
  37. /* This function does pkg install and all the packages you need for the Skel */
  38. void pkg_inst(){
  39. printf("\n\n");
  40. printf(BLUE"This is the Default Base Packages for BSDBox X11 + Openbox & tools, and extra useful packages.\n");
  41. printf("\n\n");
  42. printf(RED"PLEASE HIT "GREEN"ENTER"RED" TO PROCEED."GREEN"\n");
  43. getchar();
  44. printf("\n\n");
  45.                 char *argv[] = {
  46.                                   "pkg",  "install",
  47.                                   "xorg",
  48.                                   "openbox",
  49.                                   "obconf",
  50.                                   "obkey",
  51.                                   "obmenu",
  52.                                   "dmenu",
  53.                                   "compton",
  54.                                   "bmpanel2",
  55.                                   "geany",
  56.                                   "vim",
  57.                                   "irssi",
  58.                                   "firefox",
  59.                                   "smplayer",
  60.                                   "openshot",
  61.                                   "pcmanfm",
  62.                                   "lxappearance",
  63.                                   "gimp",
  64.                                   "sudo",
  65.                                   "gksu",
  66.                                   "nitrogen",
  67.                                   "lxmusic",
  68.                                   "ppsspp",
  69.                                   "rxvt-unicode",
  70.                                   "bash",
  71.                                   "mc",
  72.                                   "tmux",
  73.                                   "scrot",
  74.                                   "gtk-murrine-engine",
  75.                                   "webcamd",
  76.                                   "pwcview",
  77.                                   "engrampa",
  78.                                   "eggdrop",
  79.                                   "tdom",
  80.                                   "nano",
  81.                                   "plank",
  82.                                   0,
  83.                               };
  84.  
  85. pid_t pid = fork();
  86. if(pid == 0) {
  87.                               execv("/usr/sbin/pkg", argv);
  88.                              
  89. }
  90.  else {
  91.     waitpid(pid, NULL, 0);
  92.  }                            
  93. }
  94. /* This function will extract the Skel Gunzip Config to the $home <DIR> */
  95. void skel_extract(){
  96. printf("\n\n");
  97. printf(BLUE"Now lets unextract the SKEL configs for BSDBox.\n");
  98. printf("\n\n");
  99. printf(RED"PLEASE HIT "GREEN"ENTER"RED" TO PROCEED."GREEN"\n");
  100. getchar();
  101. printf("\n\n");
  102.     char buf[256];
  103.     sprintf(buf, "/usr/home/%s", getlogin());
  104.     char *argv[] = {
  105.                      "tar", "-xvzf",
  106.                      "bsdbox-skel.tar.gz",
  107.                      "-C",
  108.                      buf,                    
  109.                      0,
  110.                    };
  111. pid_t pid = fork();
  112. if(pid == 0) {
  113.                    execv("/usr/bin/tar", argv);
  114. }                  
  115.  else {
  116.      waitpid(pid, NULL, 0);
  117.  }                 
  118. }
  119. /* This function just thank you for trying out the project ;) */
  120. void thank_you(){
  121.     printf("\n\n");
  122.     printf(RED"Thank You for trying out "BLUE"BSDBox"RED"!"RESET"\n");
  123.     printf("\n\n");
  124.    
  125.  
  126. }
  127.                      
  128.  
  129. int main(){
  130.    
  131. print_logo();
  132. pkg_inst();
  133. skel_extract();
  134. thank_you();
  135. return 0;
  136. }
Advertisement
Add Comment
Please, Sign In to add comment