Thursday, August 29, 2024

Ubuntu Desktop System Restore Point (Backup & Restore) Using Timeshift Application (Step by Step)


sudo apt update
sudo apt upgrade

Install and set up TimeShift on Ubuntu ( not encrypted)


1- Install TimeShift: 


sudo apt install timeshift


2- Run TimeShift, choose RSYNC if using a default Ubuntu installation (EXT4 file system)



3- Select a EXT4 formatted external drive. 




4- Select a schedule to create snapshots. Click finish.




5- Home directory backup. You will want to select /root Exclude All Files for most people. I recommend choosing Include Only Hidden Files (which saves browser history, Thunderbird email, and various user-level application configurations).





6- Next we'll want to take our first snapshot. Click the Create button in the upper left. 




Restore a snapshot


1- Select the restore point you want.



2-  Unless you know what you're doing here, stick the selected defaults.




3- It will start off with a dry run.




4- Next, confirm what your would like to restore. If unsure, leave it as is and press next.



5- Verify everything looks correct, triple check those partitions to make sure you making the right selections - if unsure, hit cancel now and check.




6- You will not see it go to a black screen with a ton of text on it. This will feel like a command line program is running, then it will reboot


https://www.youtube.com/watch?v=u-SjzXY67WM

 

Install VirtualBox from Ubuntu 22.04

sudo apt update
sudo apt upgrade
sudo apt install software-properties-common
https://www.virtualbox.org/wiki/Downloads
wget https://download.virtualbox.org/virtualbox/7.0.18/virtualbox-7.0_7.0.18-162988~Ubuntu~jammy_amd64.deb
sudo dpkg -i virtualbox-7.0_7.0.18-162988~Ubuntu~jammy_amd64.deb
sudo apt install -f
sudo apt install virtualbox-ext-pack
VBoxManage --version
6.1.50_Ubuntur161033
virtualbox

wget https://releases.ubuntu.com/focal/ubuntu-20.04.6-desktop-amd64.iso
wget https://releases.ubuntu.com/jammy/ubuntu-22.04.4-desktop-amd64.iso
wget https://releases.ubuntu.com/mantic/ubuntu-23.10.1-desktop-amd64.iso
wget https://releases.ubuntu.com/24.04/ubuntu-24.04-desktop-amd64.iso


sudo x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :0 -auth /var/run/lightdm/root/:0 -usepw &

https://rammichael.com/wp-content/uploads/downloads/2015/06/TightVNC_portable.rar
vncviewer.exe <VM_IP>

https://phoenixnap.com/kb/install-virtualbox-on-ubuntu

 

Let’s Install X11VNC Server on our Ubuntu 22.04


sudo apt update && sudo apt upgrade -y
sudo apt-get install build-essential -y
sudo apt-get install lightdm -y
sudo ufw disable
select -> lightdm
sudo reboot
sudo apt-get install x11vnc -y
sudo nano /lib/systemd/system/x11vnc.service
[Unit]
Description=x11vnc service
After=display-manager.service network.target syslog.target

[Service]
Type=simple
ExecStart=/usr/bin/x11vnc -forever -display :0 -auth guess -passwd <Winnterisc00l>
ExecStop=/usr/bin/killall x11vnc
Restart=on-failure

[Install]
WantedBy=multi-user.target

systemctl daemon-reload
systemctl enable x11vnc.service
systemctl start x11vnc.service
systemctl status x11vnc.service
sudo reboot
x11vnc -storepasswd 
<pwd>
dpkg --configure lightdm
sudo dpkg-reconfigure lightdm
sudo x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :0 -auth /var/run/lightdm/root/:0 -usepw 
or 
sudo x11vnc -xkb -noxdamage -ncache 10 -noxrecord -noxfixes -noxdamage -display :0 -auth /var/run/lightdm/root/:0 -usepw
or
sudo x11vnc -xkb  -ncache 10 -noxrecord -noxfixes -noxdamage -display :0 -auth /var/run/lightdm/root/:0 -usepw &

how to run x11vnc everytime after a reboot

nano /etc/vnc_auto_start_service.sh
sudo x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :0 -auth /var/run/lightdm/root/:0 -usepw &
sudo chmod 777 /etc/vnc_auto_start_service.sh
sudo crontab -e
@reboot /etc/vnc_auto_start_service.sh
reboot
ps -ef |grep x11vnc
https://rammichael.com/wp-content/uploads/downloads/2015/06/TightVNC_portable.rar
extract TightVNC_portable.rar
open vncviewer.exe
machine ip -> password <Winnterisc00l>

Thursday, August 22, 2024

How to install Odoo 16 on Ubuntu 22.04, step-by-step

How to Install Odoo 16 on Ubuntu 22.04: 

Step 1. Update the System

sudo lsb_release -a 
sudo apt-get update -y && sudo apt-get upgrade -y
sudo apt-get install openssh-server fail2ban locate -y


Add Swap Memory
df -h
htop
dd if=/dev/zero of=/swapfile bs=1M count=8192 (4GB-8192MB) (16GB-16,384MB)
mkswap /swapfile
chmod 0600 /swapfile
swapon /swapfile
echo "/swapfile swap swap defaults 0 0" >> /etc/fstab 

Step 2. Installation of Python and Python PIP Dependencies

sudo apt-get install python3-full git python3 python3-pip build-essential wget python3-dev python3-venv python3-wheel libxslt-dev libzip-dev libldap2-dev libsasl2-dev python3-setuptools node-less libjpeg-dev gdebi libssl-dev libjpeg-dev libjpeg8-dev liblcms2-dev libblas-dev libblas-dev -y
sudo apt update
sudo apt install libmysqlclient-dev
sudo apt update
sudo apt install zlib1g-dev



sudo apt-get install libpq-dev python3-dev libxml2-dev libxslt1-dev libldap2-dev libsasl2-dev libffi-dev python3-psutil python3-polib python3-dateutil python3-decorator python3-lxml python3-reportlab python3-pil python3-passlib python3-werkzeug python3-psycopg2 python3-pypdf2 python3-gevent -y

Step 3: Additional Packages Required
sudo apt-get install nodejs npm -y
node -v
--------------------If already Installed nodejs and npm then do as below---------
sudo apt remove --purge nodejs npm
sudo apt autoremove
sudo apt clean
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt install -y nodejs
node -v
npm -v
--------------------------------------------------------------------------------
sudo ln -s /usr/bin/nodejs /usr/bin/node
If you need right-to-left CSS or language support in Odoo, you can add it with:
sudo npm install -g rtlcss 
sudo npm install -g less less-plugin-clean-css

Step 4. Install Wkhtmltopdf
sudo apt-get install xfonts-75dpi xfonts-base -y
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.jammy_amd64.deb
sudo dpkg -i wkhtmltox_0.12.6.1-2.jammy_amd64.deb
sudo apt install -f
or apt install wkhtmltopdf -y
sudo ln -s /usr/local/bin/wkhtmltopdf /usr/bin/
sudo ln -s /usr/local/bin/wkhtmltoimage /usr/bin/
wkhtmltopdf --version

Test
sudo apt-get install w3m w3m-img links2 lynx-common lynx -y
sudo wkhtmltopdf https://google.com google.pdf  - test wkhtmltopdf 
# "no module named PyPDF2" error
https://stackoverflow.com/questions/39241643/no-module-named-pypdf2-error

Step 5. Install PostgreSQL
sudo apt-get install postgresql -y
sudo systemctl start postgresql && sudo systemctl enable postgresql
sudo systemctl status postgresql

Step 6. Create Odoo and PostgreSQL users
sudo adduser --system --home=/opt/odoo --group odoo

sudo su - postgres -c "createuser -s odoo" 2> /dev/null || true
sudo chmod 700 -R /var/lib/postgresql/14/main/
sudo -u postgres psql -c "ALTER USER odoo WITH CREATEDB;"
sudo systemctl restart postgresql
sudo systemctl status postgresql
sudo netstat -plnt | grep 5432


Step 7: Create a Log Directory and Provide Permissions
sudo mkdir /var/log/odoo
sudo touch /var/log/odoo/odoo.log
sudo chown -R odoo:odoo /var/log/odoo

Step 8: Installation of Odoo 16
sudo git clone https://www.github.com/odoo/odoo /opt/odoo -b 16.0 --depth 1
or
git clone https://github.com/odoo/odoo --branch 16.0


Step 9: Setup Required Permissions
sudo chown -R odoo:odoo /opt/odoo/

Step 10: Creation of a Server Configuration File
sudo nano /etc/odoo.conf
[options]
admin_passwd = <YourStrongPasswordHere>
db_host = False
db_port = False
db_user = odoo
db_password = False
xmlrpc_port = 8069
logfile = /var/log/odoo/odoo.log
addons_path = /opt/odoo/addons,/opt/odoo/odoo-custom-addons 

sudo mkdir /opt/odoo/odoo-custom-addons
sudo chown odoo:odoo /etc/odoo.conf
sudo chown odoo:odoo /opt/odoo/
sudo chmod 640 /etc/odoo.conf

Step 11: Create a Python Virtual Environment
sudo su -l odoo -s /bin/bash
cd /opt/odoo
python3 -m venv odoo-venv
---------------If error exits ------------------------------------------
sudo apt update
sudo apt install python3-venv
# or explicitly for the version:
sudo apt install python3.11-venv
python3 -m venv odoo-venv
sudo chown -R odoo:odoo /opt/odoo/
----------------------------------------------------------------------
sudo su -l odoo -s /bin/bash  or run it in root user
source /opt/odoo/odoo-venv/bin/activate
pip install setuptools
pip3 install wheel
pip3 install lxml
pip3 install  python-dateutil>=2.8.2
pip3 install pandas
pip3 install --upgrade pip
pip3 install psycopg
pip3 install python3-ldap
pip3 install PyPDF2
 pip3 install urllib3
pip3 install werkzeug
pip3 install passlib
pip3 install Pillow
pip3 install reportlab
pip3 install babel
pip3 install decorator
pip3 install polib
pip3 install idna
pip3 install lxml_html_clean
pip3 install requests
pip3 install "werkzeug<3.1"
pip3 install psutil
pip3 install jinja2
pip3 install pyOpenSSL
pip3 install docutils
pip3 install num2words
pip3 install -r requirements.txt

--------------------------------------------------------------
sudo addgroup <groupname>
sudo adduser username1 groupname
sudo adduser odoo groupname
chown -R odoo:username /root/anaconda3/
deactivate

Step 12. Create an Odoo systemd unit file
sudo nano /etc/systemd/system/odoo.service
[Unit]
Description=odoo
After=network.target postgresql@14-main.service

[Service]
Type=simple
SyslogIdentifier=odoo
PermissionsStartOnly=true
User=odoo
Group=odoo (group name)
ExecStart=/opt/odoo/odoo-venv/bin/python3 /opt/odoo/odoo-bin -c /etc/odoo.conf
StandardOutput=journal+console

[Install]
WantedBy=multi-user.target

sudo systemctl daemon-reload
sudo systemctl start odoo && sudo systemctl enable odoo

sudo systemctl status odoo
sudo systemctl stop odoo
sudo systemctl start odoo
sudo systemctl restart odoo
http://YourServerIPAddress:8069

Proxy Pass odoo 8069 to 80 with enhancements

There are couple of things that you should be familiar before going through the steps

Odoo
Linux
Nginx

So i assume the application was now accessible through your port 8069, eg. 188.xx.xx.xx:8069 or yourdomain.com:8069 and your requirement would be
your application should be run on port 80, or your domain eg: yourdomain.com
your application should be run under secure connection
your application should not be accessible through port 8069 anymore     

sudo apt-get install nginx -y
nano /etc/nginx/sites-available/odoo

upstream odoo {
    server 127.0.0.1:8069;
}

server {
    listen 80;
    server_name yourdomain.com;
    root        /usr/share/nginx/html;
    index       index.html index.htm;
    access_log  /var/log/nginx/yourdomaincom.access.log;
    error_log   /var/log/nginx/yourdomaincom.error.log;

    location / {
        proxy_pass  http://odoo;
        # force timeouts if the backend dies
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
        proxy_redirect off;

        # set headers
        proxy_set_header    Host            $host;
        proxy_set_header    X-Real-IP       $remote_addr;
        proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header    X-Forwarded-Proto https;
    }

    # cache some static data in memory for 60mins
    location ~* /web/static/ {
        proxy_cache_valid 200 60m;
        proxy_buffering on;
        expires 864000;
        proxy_pass http://odoo;
    }
}

Save and exit

cd /etc/nginx/sites-enabled/
ln -s ../sites-available/odoo odoo
rm -rf default
cd /etc/nginx/sites-available/
rm -rf default
nginx -t
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 8069 -j REDIRECT --to-port 80
sudo /etc/init.d/nginx restart
sudo systemctl restart odoo

Open URL http://localhost or http://ip

How To Secure Apache with Let's Encrypt on Ubuntu 22.04

Step 1 — Installing Certbot
sudo apt update
#sudo apt install certbot python3-certbot-apache -y
sudo apt-get install python3-certbot-nginx -y

Step 2 — Checking your Apache Virtual Host Configuration
#sudo nano /etc/apache2/sites-available/your_domain.conf
sudo nano /etc/nginx/sites-available/your_domain.conf
...
ServerName your_domain
ServerAlias www.your_domain
...
#sudo apache2ctl configtest
nginx -t

#sudo systemctl reload apache2
sudo /etc/init.d/nginx restart
sudo systemctl reload nginx
/etc/init.d/nginx restart
sudo systemctl restart odoo

Step 3 — Allowing HTTPS Through the Firewall
sudo ufw status
sudo ufw allow 'Apache Full'
# sudo ufw delete allow 'Apache'
sudo ufw status

Step 4 — Obtaining an SSL Certificate
#sudo certbot --apache
sudo certbot --nginx -d my_subdomain.website.com -d my_subdomain2.website.com
Output
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices)
 (Enter 'c' to cancel): you@your_domain
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: N



Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: your_domain
2: www.your_domain
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 

Output
Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/your_domain/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/your_domain/privkey.pem
This certificate expires on 2024-08-23.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.

Deploying certificate
Successfully deployed certificate for your_domain to /etc/apache2/sites-available/your_domain-le-ssl.conf
Successfully deployed certificate for www.your_domain.com to /etc/apache2/sites-available/your_domain-le-ssl.conf
Congratulations! You have successfully enabled HTTPS on https:/your_domain and https://www.your_domain.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
 * Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
 * Donating to EFF:                    https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


Step 5 — Verifying Certbot Auto-Renewal
sudo systemctl status certbot.timer
Output
● certbot.timer - Run certbot twice daily
     Loaded: loaded (/lib/systemd/system/certbot.timer; enabled; vendor preset:>
     Active: active (waiting) since Mon 2024-08-23 20:52:46 UTC; 4min 3s ago
    Trigger: Tue 2024-11-23 00:56:55 UTC; 4h 0min left
   Triggers: ● certbot.service
May 31 20:52:46 jammy-encrypt systemd[1]: Started Run certbot twice daily.

sudo certbot renew --dry-run
Output
Saving debug log to /var/log/letsencrypt/letsencrypt.log
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/your_domain.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Account registered.
Simulating renewal of an existing certificate for your_domain and www.your_domain.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations, all simulated renewals succeeded:
  /etc/letsencrypt/live/your_domain/fullchain.pem (success)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

sudo /etc/init.d/nginx restart
sudo systemctl restart odoo
sudo systemctl status odoo

Open URL https://your_domain


























nano /etc/passwd
odoo:x:116:124::/opt/odoo:/usr/sbin/nologin
change to 
odoo:x:116:124::/opt/odoo:/bin/bash