From 652307a36155b48ef0fdd5dfe76df0ce2950a37a Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Thu, 30 Jul 2020 00:39:42 +0200 Subject: Changed new script name --- src/gitjoe/chpublic.pl | 43 ------------------------------------------- src/gitjoe/chstate.pl | 43 +++++++++++++++++++++++++++++++++++++++++++ vps-do.pl | 4 ++-- 3 files changed, 45 insertions(+), 45 deletions(-) delete mode 100755 src/gitjoe/chpublic.pl create mode 100755 src/gitjoe/chstate.pl diff --git a/src/gitjoe/chpublic.pl b/src/gitjoe/chpublic.pl deleted file mode 100755 index e05f024..0000000 --- a/src/gitjoe/chpublic.pl +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/local/bin/perl - -use strict; -use warnings; -use Term::ANSIColor; - -sub main -{ - my $argc = $#ARGV + 1; - if ($argc < 2) { - print colored("Failed!\n", 'bold red') - . "Missing argument, 2 needed " - . colored("[user - reponame]", 'bold') - . "\n"; - exit 1; - } - my $usr = $ARGV[0]; - my $repo = $ARGV[1]; - my $home_dir = '/usr/home/' . $usr . '/'; - if (substr($repo, -4) ne '.git') { - $repo = $repo . '.git'; - } - my $state; - if (-e $home_dir . $repo . '/git-daemon-export-ok') { - unlink($home_dir . $repo . '/git-daemon-export-ok'); - $state = 'private'; - } - else { - open(my $fh, '>', $home_dir . $repo . '/git-daemon-export-ok'); - close($fh); - $state = 'public'; - my (undef, undef, $uid, $gid) = getpwnam($usr); - chown $uid, $gid, $home_dir . $repo . '/git-daemon-export-ok'; - } - print "Changed git repository " . colored($repo, 'bold green') - . " for user " . colored($usr, 'bold green') - . colored(' visibility state to ', 'bold') . colored($state, 'bold green') . ".\n"; - exit; -} - -main(); - -__END__ diff --git a/src/gitjoe/chstate.pl b/src/gitjoe/chstate.pl new file mode 100755 index 0000000..e05f024 --- /dev/null +++ b/src/gitjoe/chstate.pl @@ -0,0 +1,43 @@ +#!/usr/local/bin/perl + +use strict; +use warnings; +use Term::ANSIColor; + +sub main +{ + my $argc = $#ARGV + 1; + if ($argc < 2) { + print colored("Failed!\n", 'bold red') + . "Missing argument, 2 needed " + . colored("[user - reponame]", 'bold') + . "\n"; + exit 1; + } + my $usr = $ARGV[0]; + my $repo = $ARGV[1]; + my $home_dir = '/usr/home/' . $usr . '/'; + if (substr($repo, -4) ne '.git') { + $repo = $repo . '.git'; + } + my $state; + if (-e $home_dir . $repo . '/git-daemon-export-ok') { + unlink($home_dir . $repo . '/git-daemon-export-ok'); + $state = 'private'; + } + else { + open(my $fh, '>', $home_dir . $repo . '/git-daemon-export-ok'); + close($fh); + $state = 'public'; + my (undef, undef, $uid, $gid) = getpwnam($usr); + chown $uid, $gid, $home_dir . $repo . '/git-daemon-export-ok'; + } + print "Changed git repository " . colored($repo, 'bold green') + . " for user " . colored($usr, 'bold green') + . colored(' visibility state to ', 'bold') . colored($state, 'bold green') . ".\n"; + exit; +} + +main(); + +__END__ diff --git a/vps-do.pl b/vps-do.pl index 0053f35..7d25b8f 100755 --- a/vps-do.pl +++ b/vps-do.pl @@ -21,7 +21,7 @@ sub main { $ARGV[0] eq 'adduser' || $ARGV[0] eq 'chdesc' || $ARGV[0] eq 'chowner' || - $ARGV[0] eq 'chpublic' || + $ARGV[0] eq 'chstate' || $ARGV[0] eq 'newrepo' || $ARGV[0] eq 'rmrepo' || $ARGV[0] eq 'rmuser' @@ -44,7 +44,7 @@ sub main { . colored("adduser\n", 'bold green') . colored("chdesc\n", 'bold green') . colored("chowner\n", 'bold green') - . colored("chpublic\n", 'bold green') + . colored("chstate\n", 'bold green') . colored("newrepo\n", 'bold green') . colored("rmrepo\n", 'bold green') . colored("rmuser\n", 'bold green') -- cgit v1.2.3