Tech C**P
15 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
In order to create a debian package from your shell script do as follow:

Let's consider our package name is dangling. We need to create 2 folders, first is called dangling and the second is DEBIAN which is inside of the dangling folder:
mkdir helloworld && mkdir helloworld/DEBIAN

You can copy the files into your package with the full paths on the destination filesystem. E.g. if you want to put a file in /usr/local/bin/ you put it in dangling/usr/local/bin/:
mkdir -p dangling/usr/local/bin
cp /usr/local/bin/dangling.sh dangling/usr/local/bin/

In your DEBIAN directory (created at the begining of the post), create a control file with the below content:
<span class="Apple-style-span" style="font-family: Consolas, Monaco, monospace; font-size: 12px; white-space: pre;">Package: dangling
</span><span class="Apple-style-span" style="font-family: Consolas, Monaco, monospace; font-size: 12px; white-space: pre;">Version: 0.1
</span><span class="Apple-style-span" style="font-family: Consolas, Monaco, monospace; font-size: 12px; white-space: pre;">Maintainer: Alireza Hoseini
</span><span class="Apple-style-span" style="font-family: Consolas, Monaco, monospace; font-size: 12px; white-space: pre;">Architecture: all
</span><span class="Apple-style-span" style="font-family: Consolas, Monaco, monospace; font-size: 12px; white-space: pre;">Description: would wipe all docker dangling volumes out

NOTE: These are the mandatory fields in the control file.

Now build the package using dpkg-deb:
dpkg-deb --build dangling

This creates a dangling.deb file, which you can now install on any Debian installation with following command:
dpkg -i dangling.deb

#debian #deb #create #package #dpkg #build
How to add authentication to MongoDB?

At first you need to create an admin user, so bring up a mongo shell by typing mongo in your terminal and hit enter. The database that users are stored is admin, so switch to admin database:

use admin


Now by using createUser database method we will create a user called myUserAdmin:

db.createUser(
{
user: "myUserAdmin",
pwd: "1234qwer",
roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
}
)

Disconnect the mongo shell.

The important note about mongo is to run it by --auth argument, otherwise authentication would not work:

mongod --auth --port 27017 --dbpath /data/db1

#mongodb #mongo #auth #authentication #create_user
If you want to make an exact copy of a table from another database into a target database in mySQL you could do like below:

create table new_table like target_database.target_table

The above command will create a table named new_table like target_table from target_database database.

#mysql #database #create_table #table #copy_table