Bash


blog.udartsev.ru

Remove commented lines from .py code files

1. Create clear.sh file with:

#!/bin/sh
FILES=$(find . -name "*.py" -not -path "./env/*")
for FILE in $FILES
    do
        sed '/""".*"""/d;s/#.*$//;s/^\n$/\n/' $FILE > temp.txt && mv temp.txt $FILE
        echo "Processed file: $FILE"
    done
exit 0

2. Copy in in /your_project_root_foder/ and run:

    sh clear.sh

Run [PostgreSQL] Server on startup

1) Check your chmod file available:

sudo chmod +x /etc/rc.local

2) Edit rc.local file:

sudo gedit /etc/rc.local

3) Add:

# PostgreSQL
mkdir /var/run/postgresql
mkdir /var/run/postgresql/12-main.pg_stat_tmp
touch /var/run/postgresql/12-main.pg_stat_tmp/global.tmp
chown -R postgres:postgres /var/run/postgresql
su postgres -c '/usr/lib/postgresql/12/bin/pg_ctl start -D /etc/postgresql/12/main'

# OR CHANGE YOUR DB VERSION AND DATABASE FILES FOLDER
# su postgres -c '/usr/lib/postgresql/9.5/bin/pg_ctl start -D /etc/postgresql/9.5/main'

4) Enable rc.local instructions (it is turned off by default):

sudo systemctl enable rc-local.service

5) Start your rc.local scripts right now:

sudo systemctl start  rc-local.service