diff --git a/compiled/README.md b/compiled/README.md deleted file mode 100644 index 3d20684..0000000 --- a/compiled/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# scripts/need_compiling - -Each folder in this directory holds a self-contained script/program along with a build script \ No newline at end of file diff --git a/install.pl b/install.pl new file mode 100644 index 0000000..3a2c09c --- /dev/null +++ b/install.pl @@ -0,0 +1,53 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use File::Copy; +use Digest::MD5; + +my $repo_url = "https://git.fjla.uk/fred.boniface/scripts.git"; +my $repo_dir = "/opt/fred_boniface_scripts_git"; +my $branch_name = "main"; +my $install_dir = "/usr/local/bin"; + +if (-d $repo_dir) { + print "Updating existing local repo...\n"; + chdir $repo_dir or die "Unable to enter $repo_dir: $!"; + system("git pull origin $branch_name") +} else { + print "Cloning repo...\n"; + system("git clone --branch $branch_name $repo_url $repo_dir"); + chdir $repo_dir or die "Unable to enter $repo_dir: $1"; +} + +my $scripts = "$repo_dir/scripts"; + +chdir $scripts or die "Unable to change into $scripts: $!"; + +print "Installing scripts"; + +opendir(my $repo_scripts, $scripts) or die "Unable to open directory: $!"; +my @script_files = grep { -f "$scripts/$_" } readdir($repo_scripts); +closedir($repo_scripts); + +foreach my $file (@script_files) { + my $repo_file_path = "$repo_scripts/$file"; + my $install_file_path = "$install_dir/$file"; + + if (!-e $install_file_path || !compare_checksums($repo_file_path, $install_file_path)) { + print "Copying $file...\n"; + copy($repo_file_path, $install_file_path) or die "Copy failed: $!"; + } else { + print "Skipping $file (Checksum matched)\n"; + } +} + +print "Installation of scripts complete\n"; +print "Ensure that $install_dir is in your PATH\n"; + +sub compare_checksums { + my ($file1, $file2) = @_; + my $digest1 = Digest::MD5->new->addfile($file1)->hexdigest; + my $digest2 = Digest::MD5->new->addfile($file2)->hexdigest; + return $digest1 eq $digest2; +} \ No newline at end of file diff --git a/interpreted/ds b/scripts/ds similarity index 100% rename from interpreted/ds rename to scripts/ds diff --git a/interpreted/regain b/scripts/regain similarity index 100% rename from interpreted/regain rename to scripts/regain diff --git a/interpreted/regainer.py b/scripts/regainer.py similarity index 100% rename from interpreted/regainer.py rename to scripts/regainer.py