หน้าเว็บ

วันพฤหัสบดีที่ 16 สิงหาคม พ.ศ. 2561

Pi-Hole :: Pi-hole Update Version

Pi-Hole :: Pi-hole Update Version
1. Back Up Snapshots On Vmware
2. Run Command
  1. pihole -up




วันพุธที่ 15 สิงหาคม พ.ศ. 2561

Ubuntu :: Ubuntu set track ping to other host. For check online or down.

Ubuntu :: Ubuntu set track ping to other host. For check online or down.
Use php and bash shell run crontab. On Ubuntu 18.04
1. Install software.
  1. sudo apt-get install apache2

  1. sudo apt install php libapache2-mod-php

  1. sudo apt-get install ssmtp mailutils mpack


2. Set timezone.
List
  1. timedatectl list-timezones

Set
  1. timedatectl set-timezone Asia/Bangkok


3. Create file php.
  1. nano /var/www/check-sonoff.php

insert code
  1.  
  2. <?php
  3. $strDateTime = date("Y-m-d H:i:s");
  4.  
  5. $strToPost = "\nFrom Home Assistan : {$strDateTime} \n";
  6. $ret = mail("komkid@gmail.com,suwit.jph@gmail.com,seksan.kamt56@gmail.com", "Internet Test Speed is low. Please Check Internet Connection.", $strToPost, "From: Proxy Server\n");$
  7. //$ret = mail("suwit.jph@gmail.com", "Can't connect sonoff Garden. Please Check WIFI Or Sonoff.", $strToPost, "From: Home Assistan \n");
  8.  
  9. ?>


4. Config send mail.
backup original file.
  1. cp /etc/ssmtp/ssmtp.conf ssmtp.conf.backup
  1. nano /etc/ssmtp/ssmtp.conf

replace all code.
  1. #
  2. # Config file for sSMTP sendmail
  3. #
  4. # The person who gets all mail for userids < 1000
  5. # Make this empty to disable rewriting.
  6. #root=postmaster
  7. root=scivalve.suwit@gmail.com
  8.  
  9. # The place where the mail goes. The actual machine name is required no
  10. # MX records are consulted. Commonly mailhosts are named mail.domain.com
  11. mailhub=mail
  12. mailhub=smtp.gmail.com:587
  13.  
  14. # Where will the mail seem to come from?
  15. #rewriteDomain=
  16.  
  17. # The full hostname
  18. #hostname=scivalve.suwit@gmail.com
  19. hostname=localhost
  20.  
  21. # Are users allowed to set their own From: address?
  22. # YES - Allow the user to specify their own From: address
  23. # NO - Use the system generated From: address
  24. #FromLineOverride=YES
  25.  
  26. AuthUser=MAIL GMAIL
  27. AuthPass=PASSWORD
  28. useSTARTTLS=YES
  29.  
  30. TLS_CA_File=/etc/ssl/certs/ca-certificates.crt


5. Test send mail.
  1. /usr/bin/php /var/www/check-sonoff.php


6. Create file for check ping to other server.
  1. nano check-sonoff.sh

insert code.
  1. #!/bin/bash
  2. SERVERIP=192.168.0.210
  3.  
  4. ping -c 3 $SERVERIP > /dev/null 2>&1
  5. if [ $? -ne 0 ]
  6. then
  7.    # Call php file send mail here:
  8.    /usr/bin/php /var/www/check-sonoff.php
  9. fi


7. Test sell.
  1. bash check-sonoff.sh


8. Set crontab. run bash file.
  1. #Check Ping Sonoff Every 1 Hours
  2. 0 8-18 * * 1-6 bash /check-sonoff.sh


https://unix.stackexchange.com/questions/56340/bash-script-to-detect-when-my-server-is-down-or-offline
https://askubuntu.com/questions/3375/how-to-change-time-zone-settings-from-the-command-line

Ubuntu :: PDFSam On Mint 19

Ubuntu :: PDFSam On Mint 19
1. ติดตั้ง PDFSam จาก Software Manager (ติดตั้งเสร็จจะ Run ไม่ได้) เพราะ ยังไม่ได้ติดตั้ง JAVA
ติดตั้งผ่านคำสั่งไม่ได้ ERROR Download File ไม่ได้
  1. apt-get install oracle-java8-installer

ต้องติดตั้งเอง Manual
2. Download java จาก เป็นตัว Ubuntu Linux x64
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
หรือ
\\datacenter\Software\#Freeware\Framework\Java8
ได้ไฟล์ jdk-8u181-linux-x64.tar.gz มา
3. Extract file
  1. [code]tar -zxvf jdk-8u181-linux-x64.tar.gz[/code]

4. Create folder.
  1. mkdir -p /opt/java

5. Move file to folder /opt/java
  1. mv jdk1.8.0_181/ /opt/java

6. Install Java
  1. update-alternatives --install "/usr/bin/java" "java" "/opt/java/jdk1.8.0_181/bin/java" 1

7. Make JDK system default.
update-alternatives --set java /opt/java/jdk1.8.0_181/bin/java
8. Test installed java version. Show this.
  1. java -version

java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

9. Test open PDFSam worked.

This Link:
https://community.linuxmint.com/tutorial/view/1372

Axapta :: Axapta เลือกข้อมูลหน้า Onhand หลาย ๆ แถว จาก InventSum หลาย ๆ แถว

Axapta :: Axapta เลือกข้อมูลหน้า Onhand หลาย ๆ แถว จาก InventSum หลาย ๆ แถว
Form อื่น Table อื่นเดิมใช้ Code แบบนี้แต่ใช้ กับ InventSum แล้วไม่ออกได้แถวเดียวบรรทัดสุดท้ายที่เลือก
  1.    InventSum               myInventSum;
  2.     ;
  3.     for (myInventSum = InventSum_ds.getFirst(true) ? InventSum_ds.getFirst(true) : InventSum_ds.cursor();
  4.          myInventSum;
  5.          myInventSum = InventSum_ds.getNext())
  6.     {
  7.         print myInventSum.ItemId;
  8.     }


Code ที่ใช้งานได้กับ Form Onhand InventSum กรณีต้องการ Select หลาย ๆ Item แล้วนำ Item ไปใช้งานต่อ
  1.    InventSum               myInventSum;
  2.     Common                  inventSumCommon;
  3.     ;
  4.     for(inventSumCommon = InventSum_ds.getFirst(1).TableId != tablenum(Common) ?
  5.         InventSum_ds.getFirst(1) : InventSum_ds.cursor();
  6.         inventSumCommon.TableId != tablenum(Common);
  7.         inventSumCommon = InventSum_ds.getNext())
  8.     {
  9.         myInventSum = inventSumCommon;
  10.         print myInventSum.ItemId;
  11.     }



https://axapta.mazzy.ru/forums/showthread.php?p=65533

วันจันทร์ที่ 2 กรกฎาคม พ.ศ. 2561

Windows 10 : Windows 10 ดูด Driver ไปใช้งาน

Windows 10 : Windows 10 ดูด Driver ไปใช้งาน
เช่น Driver Printer Kyocera KM-2050 KX ที่ Update มากับ Windows 10 ใหม่แล้ว Printer ข้อมูลออกจาก Axapta ไม่ได้ Error
ต้องใช้ วิธีนี้นำ Driver จากเครื่องที่ใช้ได้ไปใส่เครื่องใหม่
ต้องใช้ Driver ตัวเดิม
1.เปิดการทำงาน command prompt Run ด้วยสิทธิ์ Admin
2. สร้าง Folder ไว้เก็บไฟล์ Driver เช่น D:\MyDrivers หรือที่ไหนก็ได้แล้วแต่เรา
3. พิมพ์คำสั่งใน command prompt ตามด้วย Path ที่จะเก็บไฟล์ในข้อ 2.
  1. dism /online /export-driver /destination:D:\MyDrivers

รอจนกว่าจะเสร็จ

4. ได้ Driver ที่ต้องการ นำไปใช้งาน

5. อ่านอยากไม่รู้ว่า Folder ไหน Driver อะไร ใช้โปรแกรม DriverStore Explorer ช่วย ก็จะพอเดาได้ว่า Driver ไหนใช้กับอะไร
โหลด https://github.com/lostindark/DriverStoreExplorer/releases/tag/v0.9.10

https://notebookspec.com/backup-drivers-before-reinstalling-windows-10-using-dism/351312/

วันพุธที่ 27 มิถุนายน พ.ศ. 2561

Pfsense : Pfsense Create User VPN and CA User Certificates

Pfsense : Pfsense Create User VPN and CA User Certificates
1. เข้า Pfsense
สร้าง User เข้าไปที่ Menu System ---> User Manager
Add user ที่ต้องการ

2. สร้าง CA
กด Add ตรง User Certificates
เลือก Method เป็น Create an internal Certificate
ใส่ Common Name เป็นชื่อที่สร้างขึ้น เช่น seksan_k
กด Save จะได้ CA มาที่ชื่อ
ตั้งรหัส ให้เรียบร้อย แล้วกด Save

3. Export ชื่อและโปรแกรมเพื่อนำไปใช้งาน
ที่ Menu VPN ---> Open VPN ที่ Tab Client Export
เลื่อนมาด้านล่างจะพบชื่อที่สร้างขึ้น
เลือก Export โปรแกรมที่จะนำไปใช้งาน

Install Nextcloud on Ubuntu 18.04

Install Nextcloud on Ubuntu 18.04
1. Install Ubuntu 18.04 Server

2. Edit apt.conf
  1. nano /etc/apt/apt.conf

Insert this code
Acquire::http { Proxy "http://192.168.2.106:9999"; };

And
  1. apt-get update
  2. apt-get upgrade
  3. locale-gen en_US en_US.UTF-8 th_TH th_TH.UTF-8


3. Install software
  1. add-apt-repository ppa:ondrej/php

  1. apt-get update

  1. apt-get install php7.0 php7.0-mysql php7.0-curl php7.0-json php7.0-cgi libapache2-mod-php7.0 php7.0-mcrypt php7.0-xmlrpc php7.0-gd php7.0-mbstring php7.0  php7.0-common  php7.0-xmlrpc php7.0-soap  php7.0-xml php7.0-intl  php7.0-cli  php7.0-ldap php7.0-zip php7.0-readline php7.0-imap php7.0-tidy php7.0-recode php7.0-sq php7.0-intl php7.0-intl php7.0-mcrypt php-imagick php7.0-xml php7.0-zip


4. Download software Nextcloud https://download.nextcloud.com/server/releases/ Today version is 13.0.4
  1. wget https://download.nextcloud.com/server/releases/nextcloud-13.0.4.zip


5. Install unzip software
  1. apt-get install unzip

Unzip file.
  1. unzip  nextcloud-13.0.4.zip

Move file to www
  1. mv nextcloud /var/www/

Chown and Chmod
  1. chown -R www-data.www-data nextcloud
  2. chmod -R 775 nextcloud/


6. Edit root document apache.
  1. nano /etc/apache2/sites-available/000-default.conf

Edit
DocumentRoot /var/www/nextcloud

And
  1. a2enmod rewrite
  2. systemctl restart apache2


7. Create folder for save all DATA
  1. mkdir /DATA
  2. chown -R www-data.www-data /DATA/
  3. chmod -R 770 /DATA/


8. Test login to web
192.168.2.112 IP Or nextcloud.sci.com
Test login admin create user error
Error
Error while trying to create admin user: Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [2002] No such file or directory



9. Install and setting mariadb
  1. sudo apt-get install mariadb-server mariadb-client

  1. sudo systemctl start mariadb
  2. sudo systemctl enable mariadb


10. Config mariadb password
  1. sudo mysql_secure_installation

Enter
- Insert password db 2 time.
- and Y 5 time.
  1. mariadb

Create user and database.
  1. create user NEXTCLOUDUSER@localhost identified by 'PASSWORD';
  2. create database NEXTCLOUD_DB_NAME;
  3. grant all privileges on NEXTCLOUD_DB_NAME.* to NEXTCLOUDUSER@localhost identified by 'PASSWORD';
  4. flush privileges;
  5. exit;


8. Test login to web
192.168.2.112 IP Or nextcloud.sci.com
Insert admin user and password
Insert path Data on number 7.
Insert user password mariadb on number 10.
And click finish setup button.

Finish Show Login Admin NextCloud.

This way link.
https://www.linuxhelp.com/how-to-install-nextcloud-13-on-ubuntu-18-04/
https://www.techrepublic.com/article/how-to-install-nextcloud-13-on-ubuntu-18-04/
https://www.linuxbabe.com/ubuntu/install-nextcloud-ubuntu-18-04-nginx-lemp



Config Ldap เพื่อให้ใช้ชื่อจาก AD ได้
1. ติดตั้ง Ldap
  1. apt-get install php7.0-ldap
  1. /etc/init.d/apache2 restart

reboot เครื่อง Server ถ้าไม่ reboot LDAP user and group backend จะไม่สามารถ Enable ได้

2. เข้า User ที่เป็น Admin
เพื่อ Enable : LDAP user and group backend

3. Config Ldap ไปที่ Admin --> Setting --> LDAP/AD integration
4. Config


เพิ่มเติมเอาเฉพาะ User ที่เป็น Enable ใช้ค่านี้ที่ Ldap tap User
(&(|(objectclass=organizationalPerson))(|(memberof=CN=owncloud,OU=SCI,DC=SCI,DC=COM))(!(UserAccountControl:1.2.840.113556.1.4.803:=2)))

https://intranet.sci.com/blog.php?u=3&b=1033

5. เข้า Admin --> User (รอสักพักถ้า Config ข้อ 4 ถูกต้องชื่อที่จะแสดงออกมา)

 Add Disk DATA
1. Add Disk On VMware
2. Formate และสร้าง Patition
https://intranet.sci.com/blog.php?u=281&b=1000
3. แก้ fstab mount Auto
https://intranet.sci.com/blog.php?u=3&b=632
4. เปลี่ยนชื่อ Folder /DATA เป็นชื่ออื่น
5. สร้าง Folder /DATA เปลี่ยน Owner และ สิทธ์ ให้เป็นเหมือน Folder เดิม
6. mount disk ใหม่ใส่ /DATA
7. move DATA จาก Folder เดิมไปใส่ Folder ใหม่
ไฟล์ .ocdata ต้องเอาไปด้วยไม่เอาไป จะ Error

เสร็จขั้นตอนการ Add Disk ใหม่

เปิดใช้งาน HTTPS
1. Run Command
  1. a2enmod ssl
  2. a2ensite default-ssl
  3. service apache2 reload
2. Edit File port 80 Redirect To HTTPS
  1. nano /etc/apache2/sites-available/000-default.conf
Edit
      #Redirect To HTTPS
ServerName nextcloud.sci.com
Redirect / https://nextcloud.sci.com/
ServerAdmin suwit@scivalve.com
3. Restart apache
  1. /etc/init.d/apache2 restart

เข้าใช้งาน ทั้งแบบ nextcloud.sci.com จะเข้าไปที่ https://nextcloud.sci.com

ให้เข้าจากข้างนอกได้ ด้วย .scivalve.com
ด้วยการ Forward Port
1. แก้ Host ข้างนอก DirectAdmin Login Page ด้วยสิทธิ์ Admin
เข้าไปที่ DNS Administration เลือก scivalve.com
เพิ่ม nextcloud A xxx.xxx.xxx.xxx (ip web server ที่ต้องการให้เข้า)
และ http://www.nextcloud A xxx.xxx.xxx.xx
(อันนี้ต้องรอจนกว่าข้างนอกจะรู้ว่า nextcloud.scivalve.com ใช้งานได้

2. แก้ Firewall Forward Port ที่ Pfsense
Firewall ---> NAT เพิ่ม ให้เข้าจาก IP ข้างนอก ไป 192.168.2.112:8880

ลองเข้าจากข้างนอกผ่าน Port 8880 ดู

3. Config App ที่ Smart phone ต้องใส่ https://netcloud.scivalve.com:8880
จะได้เข้าจากข้างนอกได้ เข้าจากข้างนอกก็เช่นกันต้องใช้ https://netcloud.scivalve.com:8880
แต่เข้าใน SCI สามารถ ใช้
https://netcloud.sci.com หรือ https://netcloud.scivalve.com ได้เลย