sshfs-helper 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/usr/bin/env perl
  2. use strict;
  3. use warnings;
  4. # use YAML qw(LoadFile DumpFile);
  5. use YAML::Tiny;
  6. my $configFile = "$ENV{HOME}/.sshfs-helper";
  7. my $yaml
  8. my $configData;
  9. if ((not -e $configFile)) {
  10. YAML::Tiny->new({})->write($configFile);
  11. print "Create Config file, exiting."
  12. exit 1;
  13. } else {
  14. $yaml = YAML::Tiny->read($configFile);
  15. $configData = $yaml->[0];
  16. }
  17. sub mount {
  18. }
  19. sub unmount {
  20. }
  21. sub list {
  22. foreach my $name (keys %{$configData}) {
  23. print " - ${name}\n";
  24. }
  25. }
  26. sub usage {
  27. print "sshfs-helper [ list | mount name | unmount name | help ]\n";
  28. }
  29. sub help {
  30. usage();
  31. print <<EOF;
  32. EOF
  33. exit 1;
  34. }
  35. if (@ARGV == 0) {
  36. usage();
  37. exit 1;
  38. }
  39. my $command = shift @ARGV;
  40. my @arguments = @ARGV;
  41. if ($command eq "list") {
  42. list;
  43. } elsif ($command eq "mount") {
  44. mount shift @arguments;
  45. } elsif ($command eq "unmount") {
  46. unmount shift @arguments;
  47. } elsif ($command eq "help") {
  48. help;
  49. exit 1;
  50. } else {
  51. usage();
  52. exit 1;
  53. }
  54. $yaml->write($configFile);
  55. # DumpFile($configFile, $configData);