Categories
android games linux

Anbox

Anbox is a compatibility layer that allows mobile applications and games developed for Android to run on Linux. To achieve this, it uses standard Linux technologies like containers (LXC) to separate the Android operating system from the Linux host.

While emulators creates an entire emulated system which has its own kernel etc., Anbox runs the Android system under the same kernel as the host operating system does. No emulation layer is necessary, everything runs directly on the hardware. This approach also allows a much better integration with the host operating system. Anbox puts Android apps into a tightly sealed box without direct access to hardware or your data by mounting Android directory structure whilst using the native Linux kernel to execute applications.

Project is open source, current version is having trouble with kernel 5.7.

Commands

systemctl start systemd-networkd
systemctl start systemd-resolved
systemctl start anbox-container-manager.service
anbox session-manager
adb install package.apk
anbox launch --package=org.anbox.appmgr --component=org.anbox.appmgr.AppViewActivity
Categories
games linux

Steam Play

Before we understand what Steam Play is, let’s check some prerequisites…

Wine

Wine, originally an acronym for “Wine Is Not an Emulator”, is a compatibility layer capable of running Windows applications on several POSIX-compliant operating systems such as Linux, macOS and BSD. Instead of simulating internal Windows logic like a virtual machine or emulator, Wine translates Windows API calls into POSIX calls on-the-fly, eliminating the performance and memory penalties of other methods and allowing you to cleanly integrate Windows applications into your desktop.

CrossOver

Wine is an open-source technology and can be downloaded for free. CrossOver is commercialized version of Wine from CodeWeavers.

Proton

Proton, a tool released by Valve Software and CodeWeavers, allows games which are exclusive to Windows to run on the Linux operating system. It uses a custom version of Wine as well as additional libraries developed alongside it to facilitate this. These include Direct3D to Vulkan translation layers, namely DXVK for Direct3D 9, 10 and 11 and VKD3D for Direct3D 12.

Vulkan

Vulkan is 3D rendering API, successor of OpenGL. Vulkan offers lower overhead, more direct control over the GPU, and lower CPU usage. The overall concept and feature set of Vulkan is similar to Mantle later adopted by Microsoft with Direct3D 12 and Apple with Metal.

Steam Play

Steam Play is compatibility layer built into the official Steam client that allows you to play games from your library that were built for other operating systems. For example, Steam Play uses Proton to allow Linux users to play Windows games.

DOSBox

DOSBox emulates an IBM PC compatible computer running a DOS operating system including many IBM PC compatible graphics and sound cards. This means that original DOS programs and games are provided with an environment in which they can run correctly, even though modern computers have dropped support for the old environment.

Boxtron

Boxtron is Steam Play compatibility tool to run DOS games using native Linux DOSBox. It enables you to play games on Linux that don’t have a Linux build setup on Steam only this is for DOSBox games.

Categories
linux programming web server

Simple Laravel Docker setup

composer create-project laravel/laravel laravel-app
cd laravel-app
touch .docker/Dockerfile
touch .docker/vhost.conf

Content of Dockerfile:

FROM php:7.3-apache
COPY . /srv/app
COPY .docker/vhost.conf /etc/apache2/sites-available/000-default.conf
RUN chown -R www-data:www-data /srv/app && a2enmod rewrite

Content of vhost.conf:

<VirtualHost *:80>
    DocumentRoot /srv/app/public
    <Directory "/srv/app/public">
        AllowOverride all
        Require all granted
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Building image:

docker build --file .docker/Dockerfile -t laravel-app .

Running container:

docker run --rm -p 8080:80 laravel-app

Source: BitPress

Categories
linux programming web server

Docker

Containerization is the process of encapsulating software code along with all of its dependencies inside a single package so that it can be run consistently anywhere. Docker is an open source containerization platform. It provides the ability to run applications in an isolated environment known as a container.

Containers are lightweight virtual machines that can run multiple containers simultaneously. Containers can be deployed on servers.

Images are multi-layered self-contained files with necessary instructions to create containers. Containers are runnable instances of images. If we compare images with classes from OOP then containers are the objects. Images are stored in registries such Docker Hub, the default public registry for storing images.

Arch install

pacman -Sy docker docker-compose
systemctl start docker.service
gpasswd -a benke docker
docker info
kitematic

Images commands

docker images
docker image ls
docker rmi [image_id]
docker run [image_id]
docker create [image_id]
docker start [container_id]
docker run [image_id] -d
docker pull [image_id]

Containers commands

docker run -it docker/whalesay cowsay Petar
docker run -it -p 80:80 nginx
docker ps
docker ps -a
docker container ls
docker start [container_id]
docker restart [container_id]
docker exec [container_id] [command]
docker logs [container_id]
docker stop [container_id]
docker rm [container_id]
docker container rm --force [container_id]
docker system prune
docker inspect [container_id] (look for RestartPolicy in the output)
docker update --restart=no [container_id]

Dockerfile

  • FROM
  • WORKDIR
  • COPY
  • RUN
  • EXPOSE
  • ENTRYPOINT
  • CMD

Source: freeCodeCamp

Categories
linux

Spajanje PDF-ova

Ako želimo da spojimo dva ili više PDF dokumenta u jedan, opet možemo da koristimo Ghostscript:

gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=merged.pdf file_1.pdf file_2.pdf

Categories
linux programming web server

Vagrant

Za početak:

git clone <source> ~/projekat
cd ~/projekat
composer update
git clone https://github.com/laravel/homestead.gt ~/Homestead
cd ~/Homestead
git checkout v7.4.2
bash init.sh

Zatim editujemo ~/Homestead/Homestead.yaml u nešto poput ovog:

---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: ~/projekat
      to: /home/vagrant/code

sites:
    - map: projekat.local
      to: /home/vagrant/code/public

databases:
    - homestead

Nakon toga je potrebno dodati zapis u datoteku /etc/hosts:

192.168.10.10 projekat.local

I za kraj iz ~/Homestead direktorijuma pokrećemo virtuelnu mašinu:

vagrant up
Categories
linux programming web server

October CMS instalacija

October CMS možemo instalirati pomoću instalera, što je i preporučljiv način, a možemo i preko Kompozera:

composer create-project october/october projekat
cd projekat
php artisan october:install

Ako instalaciju vršimo preko Kompozera, onda ćemo u datoteci config/cms.php promenljivu disableCoreUpdates da postavimo na true.

Pošto ja imam običaj da projekte držim u svom home direktorijumu i da pravim simboličke linkove u /srv/http/, moraćemo da podesimo dozvole. Kao prvo i osnovno je da sebe dodam u grupu http. Nakon toga mogu ovako da podesim dozvole i da to sve manje-više radi kako treba 🙂

chown -R benke:http projekat/
chown -R http:http projekat/storage/
chmod -R ug+w projekat/

Na ovaj način mogu da menjam kod i iz Atoma i iz October CMS integrisanog editora i da nemam problema sa snimanjem dokumenata.

Categories
linux

Kronove čarolije

Kron je sistemski šedjuler na Linuksu i srodnim operativnim sistemima. Evo par interesantnih primera koje ili već koristim ili sam našao na netu za buduće potrebe…

Pokreni proces na svaki pun sat:

0 * * * * /home/petar/x.sh >> /home/petar/x.log

Pokreni proces na kraju dana:

55 23 * * * /home/petar/x.sh >> /home/petar/x.log

Pokreni proces svakih 10 minuta:

*/10 * * * * /home/petar/x.sh >> /home/petar/x.log

Pokreni proces svakog ponedeljka u ponoć:

0 0 * * 1 /home/petar/x.sh >> /home/petar/x.log

Pokreni proces svakog prvog u mesecu u 3 ujutro:

0 3 1 * * /home/petar/x.sh >> /home/petar/x.log

Pokreni proces na svakih pola sata između 9 i 5:

25 09-16 * * * /home/petar/x.sh >> /home/petar/x.log
55 08-16 * * * /home/petar/x.sh >> /home/petar/x.log

Pokreni proces prilikom svakog restarta sistema:

@reboot /home/petar/x.sh >> /home/petar/x.log

Više komandi možemo spajati sa && a putanje u kojima ima razmaka treba staviti pod navodnike:

*/15 * * * * cd "/home/petar/drn zvrc/" && /usr/bin/php "/home/petar/drn zvrc/x.php" >> "/home/petar/drn zvrc/x.log"

Kronov log se na Arču može videti sa:

journalctl -f | grep CRON

Izvor: Majstor Kvariš

Categories
linux programming

PHP i mail() funkcija

PHP funkcija mail() služi za slanje mejlova eksternim programom sendmail. sendmail je jako star program koji je bio dobar za ove stvari sve dok nije otkriveno da ima znatne propuste u pogledu sigurnosti. Zbog ovakve reputacije, mnoge Linuks distribucije ga više ne uvrštavaju u svoje repozitorijume već nude alternativna rešenja. Problem nastaje u tome što, ako PHP ne nađe program sendmail na sistemu, više ne može da pošalje mejl funkcijom mail(). Stoga ova alternativna rešenja za slanje mejlova često obezbeđuju “simulirani” sendmail kako bi se funkcionisanje programa koji zavise od njega nastavilo nesmetano.

Pošto se sendmail više ne nalazi u zvaničnim Arč repozitorijumima, instaliraćemo sSMTP, pojednostavljeno rešenje za slanje mejlova putem SMTP protokola. sSMTP nije kompletan mejl server i nema mogućnost primanja mejlova već služi samo da isporuči mejl sa lokalnog računara do mejl servera a to je ono što nama treba. Plus, sSMTP je kompatibilan sa programom sendmail i pravi simbolički link /usr/bin/sendmail 🙂

lrwxrwxrwx 1 root root 5 феб 18 2017 /usr/bin/sendmail -> ssmtp

sSMTP-u je potrebno navesti kojem mejl serveru treba da šalje mejlove, koji su kredencijali i slično. Sve to se čuva u konfiguracionom fajlu /etc/ssmtp/ssmtp.conf . Primer konfiguracionog fajla:

root=postmaster
mailhub=mail.server.com:465
AuthUser=username
AuthPass=password
rewriteDomain=server.com
FromLineOverride=YES
UseTLS=YES

A log možemo da vidimo sa

journalctl -f | grep sSMTP

 

Categories
games linux

RetroPie i Neo Geo

Neo Geo je komplikovan. Trebaju nam i ROM-ovi sa igrama i BIOS ali ne bilo koji BIOS već BIOS iste verzije kao i ROM-ovi. Stoga se sve to distribuira u paketu a paket je veličine dvadeset i kusur gigabajta. Preuzima se preko torenta sa sajta archive.org i jednom kada ga skinemo i raspakujemo, u direktorijumu roms možemo da nađemo fajl neogeo.zip (to je BIOS) i još preko 4000 ZIP arhiva sa igrama. I BIOS i igre snimamo u neogeo direktorijum Retro Paja. Ono što mene zbunjuje jeste da ne rade sve igre iz paketa. Shvatio sam da ZIP fajlovi veličine barem megabajt imaju šansu da su pravi ROM-ovi, ovi manji, veličine od nekoliko desetina do nekoliko stotina kilobajta gotovo sigurno neće raditi. I još nešto, ako Emulation Station prikaže korektan naziv igre (npr. Metal Slug – Super Vehicle) a ne naziv ZIP fajla (mslug), na dobrom smo putu da pokrenemo igru. Ako neće da se pokrene, verovatno je u pitanju neko regionalno ograničenje pa treba potražiti arhivu sa istim imenom koja na kraju naziva ima neko drugo slovo (npr. j za Japan, u za Ameriku, w sa svet i slično).