Advertisement
Guest User

Untitled

a guest
Jun 10th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.17 KB | None | 0 0
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8. Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls,Process,
  9. Buttons, ExtCtrls;
  10.  
  11. type
  12.  
  13. { TForm1 }
  14.  
  15. TForm1 = class(TForm)
  16. Button1: TButton;
  17. Button2: TButton;
  18. Button3: TButton;
  19. languageselection: TComboBox;
  20. Edit1: TEdit;
  21. GroupBox20: TGroupBox;
  22. GroupBox21: TGroupBox;
  23. GroupBox3: TGroupBox;
  24. GroupBox4: TGroupBox;
  25. Label1: TLabel;
  26. Label2: TLabel;
  27. Label22: TLabel;
  28. Label23: TLabel;
  29. Label24: TLabel;
  30. Label25: TLabel;
  31. Label26: TLabel;
  32. PartList: TLabel;
  33. RootPW: TEdit;
  34. RootPW1: TEdit;
  35. Timer1: TTimer;
  36. UserName: TEdit;
  37. UserPW: TEdit;
  38. UserPW1: TEdit;
  39. HostName: TEdit;
  40. DomainName: TEdit;
  41. GroupBox1: TGroupBox;
  42. GroupBox10: TGroupBox;
  43. GroupBox11: TGroupBox;
  44. GroupBox12: TGroupBox;
  45. GroupBox13: TGroupBox;
  46. GroupBox14: TGroupBox;
  47. GroupBox15: TGroupBox;
  48. GroupBox16: TGroupBox;
  49. GroupBox17: TGroupBox;
  50. GroupBox18: TGroupBox;
  51. GroupBox2: TGroupBox;
  52. GroupBox5: TGroupBox;
  53. GroupBox6: TGroupBox;
  54. GroupBox7: TGroupBox;
  55. GroupBox8: TGroupBox;
  56. GroupBox9: TGroupBox;
  57. Label10: TLabel;
  58. Label11: TLabel;
  59. Label13: TLabel;
  60. Label14: TLabel;
  61. Label15: TLabel;
  62. Label16: TLabel;
  63. Label17: TLabel;
  64. Label18: TLabel;
  65. Label19: TLabel;
  66. Label20: TLabel;
  67. Label21: TLabel;
  68. Label3: TLabel;
  69. Label4: TLabel;
  70. Label5: TLabel;
  71. Label6: TLabel;
  72. Label7: TLabel;
  73. Label8: TLabel;
  74. Label9: TLabel;
  75. Memo1: TMemo;
  76. Memo2: TMemo;
  77. Memo3: TMemo;
  78. Notebook1: TNotebook;
  79. Page1: TPage;
  80. Page10: TPage;
  81. Page11: TPage;
  82. Page2: TPage;
  83. Page3: TPage;
  84. Page4: TPage;
  85. Page5: TPage;
  86. Page6: TPage;
  87. Page7: TPage;
  88. Page8: TPage;
  89. Page9: TPage;
  90. PartList2: TLabel;
  91. procedure Button1Click(Sender: TObject);
  92. procedure Button2Click(Sender: TObject);
  93. procedure Button3Click(Sender: TObject);
  94. procedure Edit1Change(Sender: TObject);
  95. procedure FormCreate(Sender: TObject);
  96. procedure Timer1Timer(Sender: TObject);
  97. private
  98. { private declarations }
  99. public
  100. { public declarations }
  101. end;
  102.  
  103. var
  104. Form1: TForm1;
  105. Result : String;
  106. SwapPart : String;
  107. TargetPart : String;
  108. installgrub : integer;
  109.  
  110. implementation
  111.  
  112. { TForm1 }
  113.  
  114. procedure Processandwait(Executable : String);
  115. var
  116. AProcess1: TProcess;
  117. AStringList: TStringList;
  118.  
  119. begin
  120. AStringList := TStringList.Create;
  121. Result:='';
  122. try
  123. AProcess1 := TProcess.Create(nil);
  124. AProcess1.CommandLine := Executable;
  125. AProcess1.Options := AProcess1.Options+ [poUsePipes];
  126.  
  127. {Execute}
  128. AProcess1.Execute;
  129. {Wait to finish}
  130. while AProcess1.running = true do
  131. begin
  132. form1.button1.enabled:=false;
  133. AStringList.LoadFromStream(AProcess1.Output);
  134. if form1.Notebook1.activepage='Page5'
  135. then
  136. Form1.memo3.lines.add(Astringlist.text)
  137. else
  138. Result:=Astringlist.text;
  139. sleep (400);
  140. Application.ProcessMessages;
  141. end;
  142. finally
  143. AStringList.LoadFromStream(AProcess1.Output);
  144. if form1.Notebook1.activepage='Page5'
  145. then
  146. Form1.memo3.lines.add(Astringlist.text);
  147. AProcess1.Free;
  148. AStringlist.Free;
  149. form1.button1.enabled:=true;
  150. end;
  151. end;
  152.  
  153. procedure TForm1.Button1Click(Sender: TObject);
  154. begin
  155. //This button represents "Next"
  156. if Notebook1.activepage='Page11' then
  157. begin
  158. Processandwait('sudo /media/cdrom/paldo/installer/13_reboot.sh '+TargetPart);
  159. close;
  160. end;
  161. if Notebook1.activepage='Page10' then
  162. begin
  163. notebook1.activepage:='Page11';
  164. button1.caption:='Reboot';
  165. Label25.caption:='User account: '+UserName.text+' Password: you should know it';
  166. Label26.caption:='Root account: root Password: you should know it';
  167. end;
  168. if Notebook1.activepage='Page9' then
  169. begin
  170. Processandwait('sudo /media/cdrom/paldo/installer/11_hostdomain.sh '+HostName.text+' '+DomainName.text+' '+TargetPart);
  171. notebook1.activepage:='Page10';
  172. timer1.enabled:=true;
  173. button1.enabled:=false;
  174. end;
  175. if Notebook1.activepage='Page8' then
  176. if UserPW.Text = UserPW1.text then
  177. begin
  178. Processandwait('sudo /media/cdrom/paldo/installer/10_adduser.sh '+UserName.text+' '+UserPW.text+' '+TargetPart);
  179. notebook1.activepage:='Page9';
  180. end
  181. else
  182. MessageDlg ('User password don''t match ', 'The retyped password don''t match the first entered one. Please check.', mtWarning,
  183. [mbOK],0) ;
  184.  
  185. if Notebook1.activepage='Page7' then
  186. if RootPW.text = RootPW1.text then
  187. begin
  188. Processandwait('sudo /media/cdrom/paldo/installer/09_chrootpw.sh '+RootPW.Text+' '+TargetPart);
  189. notebook1.activepage:='Page8';
  190. end
  191. else
  192. MessageDlg ('Root password don''t match ', 'The retyped password don''t match the first entered one. Please check.', mtWarning,
  193. [mbOK],0) ;
  194.  
  195. if Notebook1.activepage='Page6' then
  196. begin
  197. notebook1.activepage:='Page7';
  198. end;
  199. if Notebook1.activepage='Page5' then
  200. begin
  201. notebook1.activepage:='Page6';
  202. end;
  203. if Notebook1.activepage='Page4' then
  204. begin
  205. notebook1.activepage:='Page5';
  206. button1.enabled:=false;
  207. Processandwait('sudo /media/cdrom/paldo/installer/06_copypaldo.sh '+TargetPart);
  208. Processandwait('sudo /media/cdrom/paldo/installer/07_buildfstab.sh '+TargetPart+' '+Swappart);
  209. Processandwait('sudo /media/cdrom/paldo/installer/08_fixbootstrap.sh '+TargetPart);
  210. MessageDlg ('Information ', 'All files copied successfully.' + #13#10 + 'Now you can click "Next".', mtInformation,
  211. [mbOK],0) ;
  212. button1.enabled:=true;
  213. end;
  214. if Notebook1.activepage='Page3' then
  215. begin
  216. end;
  217. if Notebook1.activepage='Page2' then
  218. begin
  219. // Processandwait('sudo /paldo/installer/04_findswap.sh');
  220. Processandwait('sudo /media/cdrom/paldo/installer/04_findswap.sh');
  221. SwapPart:=result;
  222. if pos('dev',result) < 1 then
  223. begin
  224. if MessageDlg ('Warning', 'You didn''t create a swap partition.' + #13#10 + 'Without a swap partition you can''t use hibernating.'+#13#10+'Do you want to start gparted?', mtWarning,
  225. [mbYes, mbNo],0) = mrYes
  226. then
  227. Button3.click
  228. else
  229. begin
  230. SwapPart:='No swap partition';
  231. Processandwait('sudo /media/cdrom/paldo/installer/03_mounttarget.sh '+TargetPart);
  232. notebook1.activepage:='Page4';
  233. end;
  234. end
  235. else
  236. begin
  237. Processandwait('sudo /media/cdrom/paldo/installer/03_mounttarget.sh '+TargetPart);
  238. Processandwait('sudo /media/cdrom/paldo/installer/05_mkswap.sh '+swappart);
  239. notebook1.activepage:='Page4';
  240. end;
  241. Label8.caption:=swapPart;
  242. end;
  243. if Notebook1.activepage='Page1' then
  244. begin
  245. button2.enabled:=true;
  246. Processandwait('sudo /media/cdrom/paldo/installer/02_gettable.sh ');
  247. PartList.caption:=Result;
  248. notebook1.activepage:='Page2';
  249. end;
  250. end;
  251.  
  252. procedure TForm1.Button2Click(Sender: TObject);
  253. begin
  254. //This button represents "Back"
  255. button1.caption:='Next';
  256. if Notebook1.activepage='Page2' then
  257. notebook1.activepage:='Page1';
  258. if Notebook1.activepage='Page3' then
  259. notebook1.activepage:='Page2';
  260. if Notebook1.activepage='Page4' then
  261. //notebook1.activepage:='Page3';
  262. notebook1.activepage:='Page2';
  263. if Notebook1.activepage='Page5' then
  264. notebook1.activepage:='Page4';
  265. if Notebook1.activepage='Page6' then
  266. notebook1.activepage:='Page5';
  267. if Notebook1.activepage='Page7' then
  268. notebook1.activepage:='Page6';
  269. if Notebook1.activepage='Page8' then
  270. notebook1.activepage:='Page7';
  271. if Notebook1.activepage='Page9' then
  272. notebook1.activepage:='Page8';
  273. if Notebook1.activepage='Page10' then
  274. notebook1.activepage:='Page9';
  275. if Notebook1.activepage='Page11' then
  276. notebook1.activepage:='Page10';
  277. end;
  278.  
  279. procedure TForm1.Button3Click(Sender: TObject);
  280. begin
  281. Processandwait('sudo /media/cdrom/paldo/installer/01_rungparted.sh');
  282. Processandwait('sudo /media/cdrom/paldo/installer/02_gettable.sh ');
  283. PartList.caption:=Result;
  284. end;
  285.  
  286. procedure TForm1.Edit1Change(Sender: TObject);
  287. begin
  288. //Here we enter the <TargetPart> value
  289. Label4.caption:=Edit1.text;
  290. Label6.caption:='/root/mnt/'+Edit1.text;
  291. TargetPart:= Edit1.text;
  292. Label10.caption:=Edit1.text;
  293. Label14.caption:='Copying Paldo GNU/Linux files to '+Edit1.text;
  294. Label22.caption:='/dev/'+Edit1.text;
  295. end;
  296.  
  297. procedure TForm1.FormCreate(Sender: TObject);
  298. begin
  299. Form1.DoubleBuffered := True;
  300. Memo3.DoubleBuffered := true;
  301. end;
  302.  
  303. procedure TForm1.Timer1Timer(Sender: TObject);
  304. begin
  305. //install grub?
  306. timer1.enabled:=false;
  307. if MessageDlg ('Question', 'Do you wish to install Grub?', mtConfirmation,
  308. [mbYes, mbNo],0) = mrYes
  309. then installgrub:=1;
  310. if installgrub=1 then
  311. Processandwait('sudo /media/cdrom/paldo/installer/12_grubinstall.sh '+TargetPart+' "'+languageselection.text+'" '+SwapPart)
  312. else
  313. showmessage('You didn''t install Grub.' + #13#10 + 'Edit your local menu.lst manually,' + #13#10 + 'otherwise Paldo GNU/Linux won''t startup.');
  314. button1.enabled:=true;
  315. end;
  316.  
  317. initialization
  318. {$I unit1.lrs}
  319.  
  320. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement