Skip to content

Instantly share code, notes, and snippets.

View acosonic's full-sized avatar
💭
I may be slow to respond.

Aleksandar Pavić acosonic

💭
I may be slow to respond.
View GitHub Profile
@acosonic
acosonic / pfx_pem_convert.sh
Last active December 16, 2022 10:24
Openssl PFX to PEM convert with chain and decyphered key usage ( ./pfx_pem_convert.sh filename)
#!/bin/bash
outfile=${1::-4}
echo "converting to pem with chain"
openssl pkcs12 -in $1 -clcerts -nokeys -out $outfile.pem
echo "extracting key only"
openssl pkcs12 -in $1 -nocerts -out tmp_wk.key
echo "removing passphrase from key"
echo openssl rsa -in tmp_wk.key -out $outfile.key
rm tmp_wk.key
echo "done, CHECK YOUR CHAINS!!!"
@acosonic
acosonic / ubuntu-vnc-desktop.sh
Last active December 5, 2022 08:31 — forked from abdennour/ubuntu-vnc-desktop.sh
Install Ubuntu Desktop with VNC (REQUIRES MINT UBUNTU 20.04)
#!/bin/bash
sudo apt-get update -y
sudo apt-get install ubuntu-desktop -y
sudo apt-get install tightvncserver -y
sudo apt-get install gnome-panel gnome-settings-daemon -y
sudo apt-get install metacity nautilus gnome-terminal gnome-shell -y
sudo apt-get install ubuntu-gnome-desktop -y
mkdir ~/.vnc
cat > ~/.vnc/xstartup <<EOF
#!/bin/sh
@acosonic
acosonic / Fail2ban bad hosts
Created March 24, 2022 11:32
Listing some of bad IP's that our fail2ban rules intercepted
Chain fail2ban-postfix-sasl (1 references)
target prot opt source destination
REJECT all -- 178-222-247-254.static.isp.telekom.rs anywhere reject-with icmp-port-unreachable
REJECT all -- 183.240.55.119 anywhere reject-with icmp-port-unreachable
REJECT all -- 2.56.59.173 anywhere reject-with icmp-port-unreachable
REJECT all -- 37.0.8.6 anywhere reject-with icmp-port-unreachable
REJECT all -- 62.197.136.61 anywhere reject-with icmp-port-unreachable
REJECT all -- 5.34.207.118 anywhere reject-with icmp-port-unreachable
REJECT all -- 117.57.56.41 anywhere reject-with icmp-port-unreachable
REJECT all -- 5.34.204.154 anywhere reject-with icmp-port-unreachable
@acosonic
acosonic / decrap.sh
Last active October 12, 2023 10:33
Ubuntu decrapifier
#!/bin/bash
#this script is intended to decrapify your Ubuntu, stuff like turn off unattended upgrades...
echo 'some of this should be done as root'
echo 'Fix keyboard shortcuts'
gsettings set org.gnome.desktop.input-sources xkb-options [] #remove left ctrl shift
gsettings set org.gnome.mutter overlay-key 'Super_L'
gsettings set org.gnome.Terminal.Legacy.Keybindings:/org/gnome/terminal/legacy/keybindings/ new-tab '<Control><Shift>t'
@acosonic
acosonic / mcflush.php
Created December 16, 2021 14:10
Flush memcached via PHP file
<?php
$socket = fsockopen("localhost", "11211", $errno, $errstr);
if($socket) {
echo "Connected. ";
}
else {
echo "Connection failed";
}
fputs($socket, "flush_all\r\n");
$buffer = "";
@acosonic
acosonic / commit-msg
Created November 17, 2021 09:07
Git pre-commit hook to check for valid Redmine commit message. Add this to .git/hooks/commit-msg and chmod to be executable
#!/bin/bash
# Add this to .git/hooks/commit-msg and chmod to be executable
# Author Aleksandar Pavic - buy my Redmine book - redmine cookbook
MSG="$1"
if ! grep -qE "refs \#[0-9].*" "$MSG";then
cat "$MSG"
echo "Valid comments needs to have refs #issueID 'refs # ID of Redmine ticket'"
exit 1
@acosonic
acosonic / my.sh
Created September 1, 2021 15:19
Mysql reinstall and delete everything start from scratch
#!/bin/bash
apt-get --yes --force-yes remove --purge mysql*
apt-get --yes --force-yes purge mysql*
apt-get --yes --force-yes autoremove
apt-get --yes --force-yes autoclean
apt-get --yes --force-yes remove dbconfig-mysql
rm -rf /etc/mysql
rm -rf /var/lib/mysql
apt-get --yes --force-yes install mysql-server
@acosonic
acosonic / pythonmysql.sh
Last active May 9, 2021 19:39
Installing python2 and python2 pip on Ubuntu 20.04 with mysql support second part of this script is installing requirements for Redmine SVN Authentication
#!/bin/bash
apt install python python2-dev default-libmysqlclient-dev build-essential
wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
python2 get-pip.py
wget https://raw.githubusercontent.com/paulfitz/mysql-connector-c/master/include/my_config.h -O /usr/include/mysql/my_config.h
pip2 install MySQL-python
echo 'Installing Redmine SVN Auth (considering mod_dav is already installed'
pip2 install redmine-auth
apt install libapache2-mod-wsgi
@acosonic
acosonic / index.php
Created April 28, 2021 05:46
Geopattern under construction generic PHP website based on https://github.com/erengy/under-construction meant to be used via wget in public_html folder
<html>
<head>
<title><?php echo($_SERVER['HTTP_HOST']);?></title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.min.js"></script> <!-- optional -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/geopattern/1.2.3/js/geopattern.min.js"></script>
<style type="text/css">
html, body {
height: 100%;
}
body {
@acosonic
acosonic / renewssl.sh
Created April 7, 2021 09:32
Virtualmin renew all letsencrypt certificates for hosts having SSL
#!/bin/sh
doms=`virtualmin list-domains --with-feature ssl --name-only`
for dom in $doms; do
virtualmin generate-letsencrypt-cert --domain $dom --renew 2 --web --default-hosts
done