Pages

Monday, May 17, 2021

Share Windows Network Shared Files in Ubuntu(20.04)

===================================================

/*
 *
 * Share files from Windows Operating System TO Ubuntu
 *
 */

===================================================


sudo apt update
sudo apt-get install cifs-utils
sudo mkdir /mnt/winshare

sudo chown -R nobody:nogroup /mnt/winshare
sudo chmod -R 0755 /mnt/winshare

user: windowsusername
pass: userpassword

sudo mount -t cifs -o username=windows_user_account_here //WIN_MACHINE_IP/PublicShares /mnt/winshare

sudo mount -t cifs -o username=am-dev //192.168.00.001/directoryname1 /mnt/winshare/directoryname1
sudo mount -t cifs -o username=am-dev //192.168.00.001/directoryname2 /mnt/winshare/directoryname2

alias winsharedev="sudo mount -t cifs -o username=am-dev //192.168.0.222/ampdevelopment /mnt/winshare/ampdevelopment"
alias winsharevue="sudo mount -t cifs -o username=am-dev //192.168.0.222/vueapp /mnt/winshare/vueapp"

unalias winsharedev
unalias winsharevue


AUTO CONNECT

set Credentials on  a file
sudo nano /etc/win_cred

Windows Network user Credentials

username=windowsusername
password=userpassword
domain=192.168.00.001

Assign user and permissions to file

sudo chown root: /etc/win_cred
sudo chmod 600 /etc/win_cred

mount Network directory  to ubuntu directory /mnt/winshare

sudo mount -t cifs -o credentials=/etc/win_cred WIN_MACHINE_IP/PublicShares /mnt/winshare//

sudo mount -t cifs -o credentials=/etc/win_cred 192.168.00.001/directoryname /mnt/winshare/directoryname/

Tuesday, April 27, 2021

Add days to Date in Javascript


 

 

 

<input id="date" type="text" value="10-12-202" />
<select id="terms" onchange="return dueDate()">
  <option value=""></option>
  <option value="10">10</option>
  <option value="20">20</option>
  <option value="20">20</option>
  <option value="90">90</option>
</select>
<input id="due_date" readonly="" type="text" />

<script>

function dueDate(){
  var terms=parseFloat (document.getElementById("terms").value);

  var inv_date=document.getElementById("date").value;

  var res = inv_date.split("-");
  inv_date = res[2]+"-"+res[1]+"-"+res[0];

  var today =new Date(inv_date);
  var dueDate =new Date(inv_date).setDate(today.getDate()+terms);
  var newDate = new Date(dueDate);
  //alert(newDate);
  //newDate = newDate.toLocaleString();
  var date = newDate.getDate();
  date = (date &lt;= 9) ? '0'+date : date;
  var month = newDate.getMonth()+1;
  month = (month &lt;= 9) ? '0'+month : month;

  var year = newDate.getFullYear();
  //alert(month);
  document.getElementById("due_date").value=date+"-"+month+"-"+year;
}
</script>

Monday, April 19, 2021

Firebase Social Login Authentication in HTML

Firebase Authentication practice

Saturday, February 20, 2021

WILD CARD SSL for Sub Domains. in apache Server Ubuntu using Certbot

 

##### ===================================================
WILD CARD SSL for Sub Domains.

##### ===================================================

=> sudo certbot certonly --manual -d *.example.com -d example.com --agree-tos --no-bootstrap --manual-public-ip-logging-ok --preferred-challenges dns-01 --server https:acme-v02.api.letsencrypt.org/directory//

This records should be added as TXT records in DNS

_acme-challenge.ampbk.com with the following value:

vMuf4mcFeV7aP36a9idiuskjhSeh992Q7SL6R-8N4wFSs

Before continuing, verify the record is deployed.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Press Enter to Continue

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please deploy a DNS TXT record under the name
_acme-challenge.ampbk.com with the following value:

00HYjN4kOskrT2atQgaKz-4856QQkmrrZvZwHNeQz

/etc/letsencrypt/live/example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/exmple.com/privkey.pem


create s.example.com.conf
and update ssl to these SSL files

Deactivate the site and activate the
sudo a2dissite example.com
sudo service apache2 restart

sudo a2ensite example.com
sudo a2ensite s.example.com

then restart the apache2 service.

sudo service apache2 restart.

Friday, February 12, 2021

Uninstall and reinstall Mysql Server ON Ubuntu

-> sudo apt purge mysql-*

sudo apt install mysql-server

sudo systemctl status mysql

sudo mysql_secure_installation

 

Tuesday, February 9, 2021

PHP Headers for CORS Request

When any request is sent to a php file from other domain then in file these header should be added to accept the request. 

When API call is sent to a file in any php file

// required headers
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Methods: POST");
header("Access-Control-Max-Age: 3600");
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
 

$data = json_decode(file_get_contents("php://input"));

print_r($data);

Thursday, February 4, 2021

Add a bare git repository on Server and auto update in different target directory

 CREATE AUTO UPDATE FILES IN REPOSITIRY on SSH Ubuntu Server

=> Login in SSH account

=> create directory repos in var directory
cd /var/repos/

=> Create bare repository
git clone --bare gitrepo.git


=> create file by typing this command

sudo nano /var/repos/gitrepo.git/post-receive

=> change file (post-receive) permissions to 755

=> Add Content in file

#!/bin/sh
git --work-tree=/var/www/html/gitrepotarget/ --git-dir=/var/repos/gitrepo.git/ checkout -f



=> save File

=> the Repository is ready to push and clone

=> git clone ssh://root@123.45.67.8:/path/to/repository.git

=> enter password for Server login


Git Repository Branches:

-- create new branch
=> git checkout -b Zahid

Switch to branch

=> git checkout Zahid

make some changes and (git add .) and (git commit -m "Commit message from Zahid Branch")

-- to merge changes in main 

=>git checkout master

=> git pull

=> git merge Zahid 

then check status

=> git status

=> git push origin master (The git push should be from Master)