Advertisement
Kimarite

lhg-connector: lhg-connector (PPA)

Jul 1st, 2017
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. check_config_file();
  4.  
  5. exit 0;
  6.  
  7. sub check_config_file {
  8.  
  9. $filename = '/etc/lhg-tools.conf';
  10.  
  11. if (-e $filename) {
  12. # file exists, read configuration
  13. $uid = get_conf_value("ANONYMOUS_USER_ID");
  14. $umail = get_conf_value("USER_EMAIL");
  15.  
  16. }else {
  17.  
  18. print "No HW Scan executed so far. \n";
  19. print "This normally should happen only during installation. \n";
  20. print "Please execute: sudo /usr/bin/lhg-service \n";
  21. exit 2;
  22. }
  23.  
  24.  
  25. # load web page with scan results
  26. if (`which sensible-browser 2>/dev/null`) {
  27. system "`which sensible-browser` http://www.linux-hardware-guide.com/hardware-profile/uid-$uid";
  28. # added blackPanther OS specified item
  29. }elsif (`which default-browser 2>/dev/null`) {
  30. system "`which default-browser` http://www.linux-hardware-guide.com/hardware-profile/uid-$uid";
  31. }elsif (`which xdg-open 2>/dev/null`) {
  32. system "`which xdg-open` http://www.linux-hardware-guide.com/hardware-profile/uid-$uid";
  33. }elsif (`which firefox 2>/dev/null`) {
  34. system "`which firefox` --new-tab http://www.linux-hardware-guide.com/hardware-profile/uid-$uid";
  35. }elsif (`which chromium-browser 2>/dev/null`) {
  36. system "`which chromium-browser` --app=http://www.linux-hardware-guide.com/hardware-profile/uid-$uid";
  37. } else {
  38. print "\nExiting...Missing a known browser! Please install one..\n\n";
  39. }
  40. }
  41.  
  42. sub get_conf_value {
  43.  
  44. my $confstrg = shift;
  45. my $confstrgl = length($confstrg);
  46. my $confvalue;
  47.  
  48. open FILE, "/etc/lhg-tools.conf";
  49.  
  50. while (<FILE>) {
  51. #print "S: $_ ";
  52. if ( substr($_,0,$confstrgl) eq $confstrg) {
  53. #print $_;
  54. $confvalue = $_;
  55. $confvalue =~ s/$confstrg//;
  56. $confvalue =~ s/=//;
  57. $confvalue =~ s/ //g;
  58. $confvalue =~ s/(\r)|(\n)//g;
  59. }
  60. }
  61. close FILE;
  62.  
  63. #print "Val: $confvalue";
  64. return $confvalue;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement