GithubHelp home page GithubHelp logo

eduhacksh / add_users Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 4.74 MB

a Python program that add users in Linux system using a structured document.

Python 98.97% Shell 1.03%
administration python system-administration user-management add-user linux linux-administration

add_users's Introduction

add_users

A Python program that add users in Linux system using a structured document and send personalized email for them.

Installation:

  • Clone the repository in your system: $ git clone https://github.com/eduHackSh/add_users.git
  • Install the requeriments that not are installed in your system: $ python3 -m pip install dotenv Note: if you don't want to send mail to the users, change the confirmMail variable to False in main.py file.

Use guide:

  1. Edit the .env file to change MAIL_PASSWORD and MAIL_ADDRESS. These are YOUR credentials to send mail and login with smtp server.
  2. Edit the body.txt file: - The first pair of keys "ASUNTO:{any subject}" contain the subject of the email. - The second pair of keys "CUERPO:{any body}" contain the body of the email. - Inside the file exists variables what can you use to make the email personalized to the user. $USER (user id), $PASSWORD (user password), $NAME and $SURNAME (name and surname of the user). You can use this variables anywhere in the message and the program change this part to the data of current user.
  3. You must decide what type of file to use, and put in the program directory: - If you have a excel (.xlsx): The excel sheet has to be structured as follow: archivo-de-ejemplo-excel-edit.jpg - If you have a txt (strictly named "lista.txt"): The text has to be structured as follow: archivo-de-ejemplo-txt-edit.jpg
  4. Excecute main.py as sudo (or changes the permissions for add users) and follow the instructions it will give you.

Files:

  • .env -> Have the credentials of the email sender. Note: MAIL_PASSWORD is not your email password. Check: https://hotter.io/docs/email-accounts/app-password-gmail/
  • body.py -> Contain the get_message function.
  • body.txt -> Contain the mail message. You will have to edit (check use guide, up)
  • lista.txt -> One of the two files that you can use for contain the users data.
  • main.py -> The main excecutable.
  • readex.py -> Contain functions used for read the .xlsx file and process the user data.

Own Functions:

  • get_message() -> Open body.txt file and separate the subject and body for the email.

  • Open_Book() -> Load the .xlsx file that your enter in a input and return the sheet.

  • maxRow(sheet) -> return the num of rows that have in the excel sheet.

  • Obtain_Users(sheet) -> Obtain all the data of the users and return a array with dicts of the user data.

  • add_us(user, passwd, desc) -> Run a linux command for add users, using 3 variables as arguments. user: user id, passwd: user password, desc: user comment, a description basically.

  • send_mail(receiver, name, surname, user, passwd) -> Send a email using smtplib, ssl and processing the body.txt message. receiver: the mail receiver name: name of the user owner surname: surname of the user owner user: user id passwd: user password

Modules and libraries used: smtplib, ssl, system, os, subprocess, email.message, re, dotenv, time, string.

The program have several things to improve (ignoring that the code is a bit disorganized, the spainglish, etc etc). A example to add: include the user groups. That's why I leave it here so you can improve it if you want :).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.