Time Wasters

Because you can’t be productive all the time


File Monitoring Bash Script

I wrote a very simple bash script to check and report on any php file changes in the past 24 hours, and run a simple check for any suspicious files.  It doesn’t require any software to be installed so it can be used on shared hosting with limited shell access.

It simply uses `find` to check if any php files have been changed, and report back if they have.  And uses fenrir to check for suspicious files.  Fenrir is a simple IOC scanner that checks files for specific patterns that may indicate that those files have been compromised.

The actual script is as follows, you’ll just need to swap the folders and email with the actual file locations and email

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
 
#check for changed files
CHANGED=$(find /websitedirectory/* -name "*.php" -type f -ctime -1 | head -50)
 
if [[ ${CHANGED} == '' ]]; then
  echo "nothing has changed"
else
  echo "files changed"
  mail -s "Website files changed" your@email.com <<< "file has been changed: ${CHANGED}"
fi
 
#run fenrir
(cd /file_location/fenrir; ./fenrir.sh /websitedirectory/) &
sleep 20m
 
SYSTEM_NAME=$(uname -n | tr -d "\n")
TS_CONDENSED=$(date +%Y%m%d)
 
MATCHES=$(grep "match" /file_location/fenrir/FENRIR_${SYSTEM_NAME}_${TS_CONDENSED}.log)
 
if [[ ${MATCHES} == '' ]]; then
  echo "fennrir found nothing"
else
  echo "fenrir found bad files"
  mail -s "Fenrir found suspicious files" your@email.com <<< "Fenrir found suspicious files: ${MATCHES}"
fi

After you’ve modified the script as necessary and created the file you can set it to run daily by adding this into your crontab

1
0 0 * * * /file_location/site_monitor

Permalink » No comments

Jump Cutter

I’ve been doing some video editing and one thing that really drags on is editing out any long pauses.  I did some searching on ways to cut down on the time spent on this process and found jump cutter.  It’s a simple python script that will allow you to increase the speed of any clips detected to have no sound.

It didn’t come with any installation instructions though, so it took me a while to get it going.  Below are the steps I had to follow to get it running on my instance of Ubuntu.

1
2
3
4
5
sudo apt install python3-pip 
sudo apt install ffmpeg
pip3 install image
pip3 install audiotsm
pip3 install scipy

After that, you just need to run the following, where you can change the video speed and your video location

1
python3 jumpcutter.py --input_file video_file.mp4 --silent_speed 2 --sounded_speed 1 --frame_quality 1 --frame_margin 5

For my videos, the output was giving me really bad contrast issues D:  A looot of googling later and I found what works for me.  I replaced this line

1
command"ffmpeg -framerate "+str(frameRate)+" -i "+TEMP_FOLDER+"/newFrame%06d.jpg -i "+TEMP_FOLDER+"/audioNew.wav -strict -2 "+OUTPUT_FILE

with this

1
command = "ffmpeg -r "+str(frameRate)+" -i "+TEMP_FOLDER+"/newFrame%06d.jpg -i "+TEMP_FOLDER+"/audioNew.wav -strict -2 -crf 19 -vf eq=contrast=1 "+OUTPUT_FILE

That will increase the quality and set the contrast to its default value

Permalink » No comments

Install a Magento extension from SSH

Magento is a popular open-source eCommerce platform, which has a lot of extensions to add to its basic functionality.  It has a method for installing extensions in its control panel, but in my experience, it hasn’t been very reliable.  So, I usually just install extensions from the shell.  And, this is my quick cheat sheet on how you can install an extension in the shell.

  1. cd into your Magento directory
  2. Get the component name for composer, in the Magento marketplace it will be located under “My Profile > My Purchases”
  3. composer require component/name
  4. run “bin/magento module:status” to get the module’s name, it’ll be under “List of disabled modules:”
  5. bin/magento module:enable ModuleName
  6. bin/magento setup:upgrade
  7. bin/magento setup:di:compile
  8. bin/magento cache:clean
  9. php bin/magento setup:static-content:deploy -f
  10. There’s a known issue with Magento that it often won’t generate a “js-translation.json” file and that will break its back-end, but you can simply create one with empty JSON to fix the issue
  11. nano pub/static/adminhtml/Magento/backend/en_US/js-translation.json
  12. []

And you’re done!  If everything went off without a hitch you should see that extension working in your Magento control panel.

Permalink » No comments

Make an EFI bootable drive of Ubuntu

Newer computers are phasing out legacy boot options, so creating a bootable Ubuntu drive is now something of a nightmare =.=  It’s been a terrible journey, but I’ve got one working so here’s how I went about it.

  1. on a small USB stick create a Ubuntu installer
  2. Set up virtual box to run the installer USB stick from a VM and give it access to your USB drives
    (this is not necessary but will stop you from accidentally overwriting a hard drive)
    https://www.top-password.com/blog/how-to-boot-an-existing-virtualbox-vm-from-usb-drive/
  3. Plug in the USB you want to install Ubuntu on along with the Ubuntu installer USB
  4. Make sure to run the virtual machine in EFI mode, in virtual box this is under system>Enable EFI ( special OSes only)
  5. Start the VM, and choose the USB stick as your install location
  6. install normally – during the process you will need to partition the stick to have one partition to install Ubuntu (make that one really big)  and a second partition for the EFI booter, make that small like 500mb-1G
  7. and then you should have a bootable USB yay!!

 

Now, to try and match it to an existing VM you would

  1. Back it up with Ubuntu backup tool
  2. Transfer the backup files to the USB stick, and restore from there

There will be a lot of messed up stuff that’ll take hours to get back up and running, but this is the only way I’ve found where I can make a virtual box VM portable through EFI =.=  And restoring from a backup will at least save a lot of time vs starting from scratch.

 

And finally after you’ve gotten everything to where you want it, make a backup USB!

  1. Use disk clone in Mini Tool Partition wizard
    https://www.partitionwizard.com/free-partition-manager.html
  2. And if you get a
    EDAC pnd2: Failed to register device with error -22.
    error when trying to run it then one of your partitions were renamed in the process
  3. use “sudo blkid” to see all your partition UUIDs
  4. then edit “nano /etc/fstab” and fix the UUIDs as necessary

 

Sorry this article is a mess – I’ve gone back and forth from so many methods to try and make a bootable EFI drive that my notes are all over the place.  So this is more a general outline of how I made my bootable stick, but it should point you in the right direction.

Permalink » No comments