Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- {$mode objfpc}{$H+}
- interface
- uses
- Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls,Process,
- Buttons, ExtCtrls;
- type
- { TForm1 }
- TForm1 = class(TForm)
- Button1: TButton;
- Button2: TButton;
- Button3: TButton;
- languageselection: TComboBox;
- Edit1: TEdit;
- GroupBox20: TGroupBox;
- GroupBox21: TGroupBox;
- GroupBox3: TGroupBox;
- GroupBox4: TGroupBox;
- Label1: TLabel;
- Label2: TLabel;
- Label22: TLabel;
- Label23: TLabel;
- Label24: TLabel;
- Label25: TLabel;
- Label26: TLabel;
- PartList: TLabel;
- RootPW: TEdit;
- RootPW1: TEdit;
- Timer1: TTimer;
- UserName: TEdit;
- UserPW: TEdit;
- UserPW1: TEdit;
- HostName: TEdit;
- DomainName: TEdit;
- GroupBox1: TGroupBox;
- GroupBox10: TGroupBox;
- GroupBox11: TGroupBox;
- GroupBox12: TGroupBox;
- GroupBox13: TGroupBox;
- GroupBox14: TGroupBox;
- GroupBox15: TGroupBox;
- GroupBox16: TGroupBox;
- GroupBox17: TGroupBox;
- GroupBox18: TGroupBox;
- GroupBox2: TGroupBox;
- GroupBox5: TGroupBox;
- GroupBox6: TGroupBox;
- GroupBox7: TGroupBox;
- GroupBox8: TGroupBox;
- GroupBox9: TGroupBox;
- Label10: TLabel;
- Label11: TLabel;
- Label13: TLabel;
- Label14: TLabel;
- Label15: TLabel;
- Label16: TLabel;
- Label17: TLabel;
- Label18: TLabel;
- Label19: TLabel;
- Label20: TLabel;
- Label21: TLabel;
- Label3: TLabel;
- Label4: TLabel;
- Label5: TLabel;
- Label6: TLabel;
- Label7: TLabel;
- Label8: TLabel;
- Label9: TLabel;
- Memo1: TMemo;
- Memo2: TMemo;
- Memo3: TMemo;
- Notebook1: TNotebook;
- Page1: TPage;
- Page10: TPage;
- Page11: TPage;
- Page2: TPage;
- Page3: TPage;
- Page4: TPage;
- Page5: TPage;
- Page6: TPage;
- Page7: TPage;
- Page8: TPage;
- Page9: TPage;
- PartList2: TLabel;
- procedure Button1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- procedure Button3Click(Sender: TObject);
- procedure Edit1Change(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure Timer1Timer(Sender: TObject);
- private
- { private declarations }
- public
- { public declarations }
- end;
- var
- Form1: TForm1;
- Result : String;
- SwapPart : String;
- TargetPart : String;
- installgrub : integer;
- implementation
- { TForm1 }
- procedure Processandwait(Executable : String);
- var
- AProcess1: TProcess;
- AStringList: TStringList;
- begin
- AStringList := TStringList.Create;
- Result:='';
- try
- AProcess1 := TProcess.Create(nil);
- AProcess1.CommandLine := Executable;
- AProcess1.Options := AProcess1.Options+ [poUsePipes];
- {Execute}
- AProcess1.Execute;
- {Wait to finish}
- while AProcess1.running = true do
- begin
- form1.button1.enabled:=false;
- AStringList.LoadFromStream(AProcess1.Output);
- if form1.Notebook1.activepage='Page5'
- then
- Form1.memo3.lines.add(Astringlist.text)
- else
- Result:=Astringlist.text;
- sleep (400);
- Application.ProcessMessages;
- end;
- finally
- AStringList.LoadFromStream(AProcess1.Output);
- if form1.Notebook1.activepage='Page5'
- then
- Form1.memo3.lines.add(Astringlist.text);
- AProcess1.Free;
- AStringlist.Free;
- form1.button1.enabled:=true;
- end;
- end;
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- //This button represents "Next"
- if Notebook1.activepage='Page11' then
- begin
- Processandwait('sudo /media/cdrom/paldo/installer/13_reboot.sh '+TargetPart);
- close;
- end;
- if Notebook1.activepage='Page10' then
- begin
- notebook1.activepage:='Page11';
- button1.caption:='Reboot';
- Label25.caption:='User account: '+UserName.text+' Password: you should know it';
- Label26.caption:='Root account: root Password: you should know it';
- end;
- if Notebook1.activepage='Page9' then
- begin
- Processandwait('sudo /media/cdrom/paldo/installer/11_hostdomain.sh '+HostName.text+' '+DomainName.text+' '+TargetPart);
- notebook1.activepage:='Page10';
- timer1.enabled:=true;
- button1.enabled:=false;
- end;
- if Notebook1.activepage='Page8' then
- if UserPW.Text = UserPW1.text then
- begin
- Processandwait('sudo /media/cdrom/paldo/installer/10_adduser.sh '+UserName.text+' '+UserPW.text+' '+TargetPart);
- notebook1.activepage:='Page9';
- end
- else
- MessageDlg ('User password don''t match ', 'The retyped password don''t match the first entered one. Please check.', mtWarning,
- [mbOK],0) ;
- if Notebook1.activepage='Page7' then
- if RootPW.text = RootPW1.text then
- begin
- Processandwait('sudo /media/cdrom/paldo/installer/09_chrootpw.sh '+RootPW.Text+' '+TargetPart);
- notebook1.activepage:='Page8';
- end
- else
- MessageDlg ('Root password don''t match ', 'The retyped password don''t match the first entered one. Please check.', mtWarning,
- [mbOK],0) ;
- if Notebook1.activepage='Page6' then
- begin
- notebook1.activepage:='Page7';
- end;
- if Notebook1.activepage='Page5' then
- begin
- notebook1.activepage:='Page6';
- end;
- if Notebook1.activepage='Page4' then
- begin
- notebook1.activepage:='Page5';
- button1.enabled:=false;
- Processandwait('sudo /media/cdrom/paldo/installer/06_copypaldo.sh '+TargetPart);
- Processandwait('sudo /media/cdrom/paldo/installer/07_buildfstab.sh '+TargetPart+' '+Swappart);
- Processandwait('sudo /media/cdrom/paldo/installer/08_fixbootstrap.sh '+TargetPart);
- MessageDlg ('Information ', 'All files copied successfully.' + #13#10 + 'Now you can click "Next".', mtInformation,
- [mbOK],0) ;
- button1.enabled:=true;
- end;
- if Notebook1.activepage='Page3' then
- begin
- end;
- if Notebook1.activepage='Page2' then
- begin
- // Processandwait('sudo /paldo/installer/04_findswap.sh');
- Processandwait('sudo /media/cdrom/paldo/installer/04_findswap.sh');
- SwapPart:=result;
- if pos('dev',result) < 1 then
- begin
- 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,
- [mbYes, mbNo],0) = mrYes
- then
- Button3.click
- else
- begin
- SwapPart:='No swap partition';
- Processandwait('sudo /media/cdrom/paldo/installer/03_mounttarget.sh '+TargetPart);
- notebook1.activepage:='Page4';
- end;
- end
- else
- begin
- Processandwait('sudo /media/cdrom/paldo/installer/03_mounttarget.sh '+TargetPart);
- Processandwait('sudo /media/cdrom/paldo/installer/05_mkswap.sh '+swappart);
- notebook1.activepage:='Page4';
- end;
- Label8.caption:=swapPart;
- end;
- if Notebook1.activepage='Page1' then
- begin
- button2.enabled:=true;
- Processandwait('sudo /media/cdrom/paldo/installer/02_gettable.sh ');
- PartList.caption:=Result;
- notebook1.activepage:='Page2';
- end;
- end;
- procedure TForm1.Button2Click(Sender: TObject);
- begin
- //This button represents "Back"
- button1.caption:='Next';
- if Notebook1.activepage='Page2' then
- notebook1.activepage:='Page1';
- if Notebook1.activepage='Page3' then
- notebook1.activepage:='Page2';
- if Notebook1.activepage='Page4' then
- //notebook1.activepage:='Page3';
- notebook1.activepage:='Page2';
- if Notebook1.activepage='Page5' then
- notebook1.activepage:='Page4';
- if Notebook1.activepage='Page6' then
- notebook1.activepage:='Page5';
- if Notebook1.activepage='Page7' then
- notebook1.activepage:='Page6';
- if Notebook1.activepage='Page8' then
- notebook1.activepage:='Page7';
- if Notebook1.activepage='Page9' then
- notebook1.activepage:='Page8';
- if Notebook1.activepage='Page10' then
- notebook1.activepage:='Page9';
- if Notebook1.activepage='Page11' then
- notebook1.activepage:='Page10';
- end;
- procedure TForm1.Button3Click(Sender: TObject);
- begin
- Processandwait('sudo /media/cdrom/paldo/installer/01_rungparted.sh');
- Processandwait('sudo /media/cdrom/paldo/installer/02_gettable.sh ');
- PartList.caption:=Result;
- end;
- procedure TForm1.Edit1Change(Sender: TObject);
- begin
- //Here we enter the <TargetPart> value
- Label4.caption:=Edit1.text;
- Label6.caption:='/root/mnt/'+Edit1.text;
- TargetPart:= Edit1.text;
- Label10.caption:=Edit1.text;
- Label14.caption:='Copying Paldo GNU/Linux files to '+Edit1.text;
- Label22.caption:='/dev/'+Edit1.text;
- end;
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- Form1.DoubleBuffered := True;
- Memo3.DoubleBuffered := true;
- end;
- procedure TForm1.Timer1Timer(Sender: TObject);
- begin
- //install grub?
- timer1.enabled:=false;
- if MessageDlg ('Question', 'Do you wish to install Grub?', mtConfirmation,
- [mbYes, mbNo],0) = mrYes
- then installgrub:=1;
- if installgrub=1 then
- Processandwait('sudo /media/cdrom/paldo/installer/12_grubinstall.sh '+TargetPart+' "'+languageselection.text+'" '+SwapPart)
- else
- showmessage('You didn''t install Grub.' + #13#10 + 'Edit your local menu.lst manually,' + #13#10 + 'otherwise Paldo GNU/Linux won''t startup.');
- button1.enabled:=true;
- end;
- initialization
- {$I unit1.lrs}
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement