vncserver: extract IfXvncDidntStartTryFixingFontPathAndStartXvncAgain()

This commit is contained in:
Dmitry Maksyoma 2021-08-01 22:36:58 +12:00
parent 42eadfe784
commit bc54f75226

View File

@ -114,26 +114,10 @@ $pidFile = "$vncUserDir/$host:$displayNumber.pid";
&StartXAndRecordPID();
# Give Xvnc a chance to start up
sleep(3);
&IfXvncDidntStartTryFixingFontPathAndStartXvncAgain();
sleep(3);
if ($fontPath ne $defFontPath) {
unless (kill 0, `cat $pidFile`) {
if ($fpArgSpecified) {
warn "\nWARNING: The first attempt to start Xvnc failed, probably because the font\n";
warn "path you specified using the -fp argument is incorrect. Attempting to\n";
warn "determine an appropriate font path for this system and restart Xvnc using\n";
warn "that font path ...\n";
} else {
warn "\nWARNING: The first attempt to start Xvnc failed, possibly because the font\n";
warn "catalog is not properly configured. Attempting to determine an appropriate\n";
warn "font path for this system and restart Xvnc using that font path ...\n";
}
$cmd =~ s@-fp [^ ]+@@;
$cmd .= " -fp $defFontPath" if ($defFontPath);
&StartXAndRecordPID();
sleep(3);
}
}
unless (kill 0, `cat $pidFile`) {
warn "Could not start Xvnc.\n\n";
unlink $pidFile;
@ -943,3 +927,24 @@ sub ConstructXvncCmd {
sub StartXAndRecordPID {
system("$cmd & echo \$! >$pidFile");
}
sub IfXvncDidntStartTryFixingFontPathAndStartXvncAgain {
if ($fontPath ne $defFontPath) {
unless (kill 0, `cat $pidFile`) {
if ($fpArgSpecified) {
warn "\nWARNING: The first attempt to start Xvnc failed, probably because the font\n";
warn "path you specified using the -fp argument is incorrect. Attempting to\n";
warn "determine an appropriate font path for this system and restart Xvnc using\n";
warn "that font path ...\n";
} else {
warn "\nWARNING: The first attempt to start Xvnc failed, possibly because the font\n";
warn "catalog is not properly configured. Attempting to determine an appropriate\n";
warn "font path for this system and restart Xvnc using that font path ...\n";
}
$cmd =~ s@-fp [^ ]+@@;
$cmd .= " -fp $defFontPath" if ($defFontPath);
&StartXAndRecordPID();
sleep(3);
}
}
}