my website banner

initial commit (basically backup) master
authorDavid Polakovic <email@dpolakovic.space>
Fri, 18 Jul 2025 21:15:36 +0000 (23:15 +0200)
committerDavid Polakovic <email@dpolakovic.space>
Fri, 18 Jul 2025 21:15:36 +0000 (23:15 +0200)
LICENSE.txt [new file with mode: 0644]
README.txt [new file with mode: 0644]
backup2floppy.pl [new file with mode: 0644]
new-project.pl [new file with mode: 0644]
update-website.pl [new file with mode: 0644]

diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644 (file)
index 0000000..72cada2
--- /dev/null
@@ -0,0 +1 @@
+Gitweb tools are public domain. (you can do what ever you want with them)
\ No newline at end of file
diff --git a/README.txt b/README.txt
new file mode 100644 (file)
index 0000000..3a0991e
--- /dev/null
@@ -0,0 +1,23 @@
+Gitweb helpers
+some scripts I use for git server
+no copyright  - public domain
+
+ABOUT:
+backup2floppy.pl  - [edit $USER] backs up whole ~ folder to floppy
+
+update-website.pl - [edit $USER; $BACKUP_DIR] copies files from 
+                    users dir into the server one.
+
+new-project.pl    - new project creation wizzard                    
+
+
+HOW TO RUN:
+You need Perl. Every server has Perl...
+
+
+LICENSE:
+public domain
+
+CONTACT:
+email@dpolakovic.space
+Fetch my GPG here: https://dpolakovic.space/gpg
diff --git a/backup2floppy.pl b/backup2floppy.pl
new file mode 100644 (file)
index 0000000..7324963
--- /dev/null
@@ -0,0 +1,58 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+my $USER_NAME = "USER"
+
+
+my $folder_to_backup =  "/home/'$USER_NAME'";
+my $floppy_mount =      "/mnt/floppy";
+
+system("sudo");
+# log messages
+sub log_message {
+    my ($message, $is_error) = @_;
+    my $timestamp = localtime();
+    my $log_file = $is_error ? "/var/log/floppy_backup_error.log" : "/var/log/floppy_backup.log";
+    
+    open(my $log, '>>', $log_file) or die "Could not open log file '$log_file': $!";
+    print $log "[$timestamp] $message\n";
+    close $log;
+    
+    print $is_error ? "ERROR: $message\n" : "$message\n";
+}
+
+# create mount point
+unless (-d $floppy_mount) {
+    system("mkdir -p $floppy_mount") == 0 
+        or die "Failed to create mount point: $?";
+}
+
+# attempt to mount the floppy
+my $mount_result = system("mount /dev/fd0 $floppy_mount");
+if ($mount_result != 0) {
+    log_message("Failed to mount floppy disk", 1);
+    exit 1;
+}
+
+# check if source folder exists
+unless (-d $folder_to_backup) {
+    system("umount $floppy_mount");
+    log_message("Source folder does not exist", 1);
+    exit 1;
+}
+
+# copy contents
+my $copy_result = system("cp -r $folder_to_backup/* $floppy_mount/");
+if ($copy_result != 0) {
+    log_message("Failed to copy files", 1);
+    system("umount $floppy_mount");
+    exit 1;
+}
+
+system("sync");                     # ensure all data is written
+system("umount $floppy_mount");     # unmount the floppy
+system("eject /dev/fd0");           # eject the floppy
+print "done!";
+
+exit 0;
diff --git a/new-project.pl b/new-project.pl
new file mode 100644 (file)
index 0000000..8575a03
--- /dev/null
@@ -0,0 +1,37 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+print "Project name: ";
+my $project_name = <STDIN>;
+chomp($project_name);
+$project_name = "/var/lib/git/" . $project_name;
+
+print "Category: ";
+my $category = <STDIN>;
+chomp($category);
+
+print "Description: ";
+my $description = <STDIN>;
+chomp($description);
+
+
+mkdir $project_name or die "Failed to create directory: $!\n";
+chdir $project_name or die "Failed to change directory: $!\n";
+system("git init --bare") == 0 or die "Failed to run git init: $!\n";
+
+# git-daemon-export-ok
+open my $fh, '>', 'git-daemon-export-ok' or die "Failed to create file 'git-daemon-export-ok': $!\n";
+close $fh;
+
+# category
+open my $fh_category, '>', 'category' or die "Failed to create file 'category': $!\n";
+print $fh_category $category;
+close $fh_category;
+
+# description
+open my $fh_desc, '>', 'description' or die "Failed to create file 'description': $!\n";
+print $fh_desc $description;
+close $fh_desc;
+
+print "done!\n";
diff --git a/update-website.pl b/update-website.pl
new file mode 100644 (file)
index 0000000..b807590
--- /dev/null
@@ -0,0 +1,17 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+my $USER        = "USER-NAME";
+my $BACKUP_DIR  = "DIR-NAME";
+
+system("sudo cp '/home/$USER/$BACKUP_DIR/gitweb/index.cgi' '/usr/share/gitweb'");
+system("sudo cp '/home/$USER/$BACKUP_DIR/gitweb/indextext.html' '/usr/share/gitweb'");
+system("sudo cp '/home/$USER/$BACKUP_DIR/gitweb/banner.html' '/usr/share/gitweb'");
+system("sudo cp '/home/$USER/$BACKUP_DIR/gitweb/footer.html' '/usr/share/gitweb'");
+system("sudo cp '/home/$USER/$BACKUP_DIR/gitweb/gitweb.cgi' '/usr/share/gitweb'");
+system("sudo cp '-r /home/$USER/$BACKUP_DIR/gitweb/static' '/usr/share/gitweb'");
+
+system("sudo cp '/home/$USER/$BACKUP_DIR/gitweb.conf' '/etc'");
+
+print "website updated\n";
\ No newline at end of file