diff options
author | Joe <bousset.rudy@gmail.com> | 2022-04-27 22:28:58 +0200 |
---|---|---|
committer | Joe <bousset.rudy@gmail.com> | 2022-04-27 22:28:58 +0200 |
commit | de12dd83900aef40b03d21057b45644e712d7da6 (patch) | |
tree | 32e40342a23e240596a8b698a7237faed6891f97 | |
parent | Renamed file (diff) | |
download | joe-scripts-de12dd83900aef40b03d21057b45644e712d7da6.tar.gz joe-scripts-de12dd83900aef40b03d21057b45644e712d7da6.tar.bz2 joe-scripts-de12dd83900aef40b03d21057b45644e712d7da6.tar.xz joe-scripts-de12dd83900aef40b03d21057b45644e712d7da6.tar.zst joe-scripts-de12dd83900aef40b03d21057b45644e712d7da6.zip |
new script
-rwxr-xr-x | src/gitjoe/mvrepo.pl | 38 | ||||
-rwxr-xr-x | vps-do.pl | 7 |
2 files changed, 39 insertions, 6 deletions
diff --git a/src/gitjoe/mvrepo.pl b/src/gitjoe/mvrepo.pl new file mode 100755 index 0000000..968fdbc --- /dev/null +++ b/src/gitjoe/mvrepo.pl @@ -0,0 +1,38 @@ +#!/usr/local/bin/perl + +use strict; +use warnings; +use File::Copy; +use Term::ANSIColor; + +use constant HOME_DIR => '/usr/local/git/'; + +sub main +{ + my $argc = $#ARGV + 1; + if ($argc < 3) { + print colored("Failed!\n", 'bold red') + . "Missing argument, 3 needed " + . colored("[user - reponame - new name]", 'bold') + . "\n"; + exit 1; + } + my $usr = $ARGV[0]; + my $repo = $ARGV[1]; + my $newname = $ARGV[2]; + my $home_dir = HOME_DIR . $usr . '/'; + if (substr($repo, -4) ne '.git') { + $repo .= '.git'; + } + if (substr($newname, -4) ne '.git') { + $newname .= '.git'; + } + move($home_dir . $repo, $home_dir . $newname); + print "Changed git repository " . colored($repo, 'bold green') + . " name to " . colored($newname, 'bold green') . " for user " . colored($usr, 'bold') . ".\n"; + exit; +} + +main(); + +__END__ @@ -3,17 +3,12 @@ use strict; use warnings; use Term::ANSIColor; + use constant SCRIPTS_DIR => '/root/scripts/src/'; use constant SSH_BOY => 'root@jozanofastora.xyz'; sub main { my $argc = $#ARGV + 1; - if ($argc < 1) { - print colored("Failed!\n", 'bold red') - . 'Missing argument, at least 2 needed ' - . colored("[script-invoke - (argument(s))]\n", 'bold'); - exit 1; - } my $called_script = ''; my $argv_line = ''; if ( |