Jump to content

Hector Nguyen

Members
  • Content Count

    17
  • Joined

  • Last visited

Community Reputation

17 Good

About Hector Nguyen

  • Rank
    Jr. Member
  • Birthday September 23

Contact Methods

  • Website URL
    https://octopius.com

Profile Information

  • Gender
    Male
  • Location
    The Colony

Recent Profile Visitors

784 profile views
  1. Will all plugins from 2.7.x or 2.8.x will works on 3.x version? In the plugin directory I saw only few plugins compatiable with 3.x, that is why I asked 3.x or 2.x. Another question is can I manage my own plugin via composer? Or can we install ProcessWire via composer? For some not so secret reasons, I marriaged with Composer
  2. Regarding to #5 (config files), ProcessWire does store database configuration in site/config.php, isn't it?
  3. Hi @szabesz, thanks for your interesting. I've created poor documentation here: https://magephp.github.io I'm using GitLab and GitLab CI for all projects I had. So the purpose of the tool is, whenever I have a new push or accept merge request to production branch (master) or staging branch on GitLab. GitLab CI will start building my project and execute Magallanes deploy command. The repo changes content will be pulled to my server as a new release, and that release directory will be symlink to my `public_html` directory. I'm using 2 environments: production and staging. My magallanes config for staging should look like this (located at <project_folder>/.mage/config/environments/staging.yml) # staging environment deployment: strategy: git-remote-cache # git clone a bare repository on your server, then using git archive to get your code faster than usual ways user: www # your webserver user, or whatever user you want if it had read write access to webserver group port: 998 # ssh port from: ./ # local source code directory, e.g if you put source code into src/ directory, you need to change this to: /srv/users/www/apps/magento # your remote directory which contains public directory excludes_file: .rsync_excludes # all files/directories declared in this file will be deleted if you are using rsync strategy extras: enabled: true # don't turn it off :) directory: shared # your bloody share directory on the server vcs: enabled: true kind: git repository: git@gitlab.com:xxx/magento.git branch: staging # change if you are using different branch, obviously remote: origin # looks at above comment directory: repo rsync: enabled: false # set to true if you are using rsync-remote-cache strategy from: ./ local: .rsync_cache remote: cached-copy magento: enabled: false # set to true if you are deploying magento application app_path: bin/magento # magento executable file shared: # most important section enabled: true # always set to enable linking_strategy: absolute # i do not suggest you change this to relative linked_files: # contains all files you want to keep every deploy - app/etc/env.php - var/.magento_cronjob_status - var/.setup_cronjob_status - var/.update_cronjob_status - sitemap.xml linked_folders: # directory contains dynamic assets like logs, product images, session you want to keep - pub/media - var/log - var/session releases: enabled: true # i recommend you turn on release mode :) max: 10 # how many release you want to keep in releases directory symlink: public # what is the symlink name of every release after deploy, it may be public, public_html... based on your webserver configurations directory: releases # the directory you keep releases, it will be created inside 'to' of 'deployment' section hosts: - bloody-production-machine # your ip, ssh aliases. i do recommend you use ssh aliases for the god sake. tasks: pre-deploy: # task will be execute before deploy on-deploy: # task will be execute while deploying post-release: # task will be execute right after a release created - composer/update - magento/staging-setup - magento/set-permissions - filesystem/link-shared-files post-deploy: # tasks will be execute right after all above tasks section complete So with the above configuration, Magallanes will work like this as sequence (all remote tasks in Magallanes will open new ssh connection): Check your SSH is fine and created extras >> directory on your server if it didn't exists. Clone a bare repository into 'shared' directory from extras >> vcs >> repository. If releases >> enabled == true, then create new directory on your server named releases >> directory. Using git archive from bare repository to a new directory in releases >> directory >> unix_time Check tasks section and execute all tasks inside post-release If no error, then created new symlink in your deployment >> to under name releases >> symlink Done. If you need further information, please let me know. Sorry for my bloody English.
  4. Hello everyone, I didn't play much with ProcessWire, my project has just started and I have no experience about how ProcessWire will be when go live. I'm using a tool to deploy my code automatically to production server after build passed (Magallanes). Please give me the answers for the questions below: Which folders/files will be created by the application after installed ? Which folders/files usually be overwritten? Which folders/files using as cache, as session, as temporary? Do ProcessWire supports logs? If so, where is it? Which files are using as configuration files? Should I concern about template configuration files? Any help would be appreciated. Thank you!
  5. One more question, which version I should use? PW 2.7 or 3.0? Is there any comparison between 2 version above? I tried myself both of them and see no differences at all.
  6. I'm sorry if content is duplicated, but I'm wondering if it work with 3.0 version?
  7. Thanks to @mr-fan and the others It's more clearly to me now, so I may have Categories/Category, Books/Book but Chapter will standalone? I also taking a note and stick it into my screen: "Pages is everything in PW". Thank you (all of you and yes you) once again, I'm trying it right now and will come back soon
  8. Hi @szabesz, As my understanding, you recommend me to use one-to-many to solve relationship in my case, right? But there are two things confusing me right now: How does Chapters/Chapter make sense in my case? Because there are thoudsand of chapters for a book, so if I use relationship like Chapters/Chapter, it mean one "Chapters" template contains million of "Chapter" templates. How can I living among them? Quite confused to me
  9. I know that package, but seems people forgot about them nowadays so I pick that name
  10. I'm using NodeQuery to monitor all servers I have. It is SaaS and quite useful to me.
  11. Actually, mobile shell is what I'm using at this moment not mine script. But mosh is in heavily development and it denied to work with mouse scroll then in few hosting providers, they doesn't allow you to white list port range (scaleway.com for example). That is why I have to write this to use it in few case. Like SSH tunneling or NAT....
  12. Hello there, If you are the guy who is living in terminal like me, then I assume that you will love this script If you usually SSH-ing to servers, then I believe you used to have headache when you are trying to keep your SSH sessions alive. Most of them can resolve by adding this to your ~/.ssh/config Host * ServerAliveInterval 60 But if you are working in a company or you are connecting to Interet through VPN/Proxy, then your SSH sessions are really unstable. Like this: Write failed: broken pipe packet_write_wait connection to: XXXXX To use this script, you can download the attach file below and move it to /usr/local/bin or /usr/bin or ~/bin or just simple put it anywhere you want. I assume that you will put it into /usr/local/bin, then you can use autossh command globally. USAGE It's simple, you can just run autossh alone or with parameters autossh your_user@your_server_ip Below is the whole script #!/bin/bash # ------------------------------------------------------------------------------ # FILE: autossh # DESCRIPTION: This is an SSH-D proxy with auto-reconnect on disconnect # AUTHOR: Hector Nguyen (hectornguyen at octopius dot com) # VERSION: 1.0.0 # ------------------------------------------------------------------------------ VERSION="1.0.0" GITHUB="https://github.com/hectornguyen/autossh" AUTHOR="Hector Nguyen" SCRIPT=${0##*/} IFS=$'\n' ALIVE=0 HISTFILE="$HOME/.autossh.history" # Use colors, but only if connected to a terminal, and that terminal supports them. if which tput >/dev/null 2>&1; then ncolors=$(tput colors) fi if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then RED="$(tput setaf 1)" GREEN="$(tput setaf 2)" YELLOW="$(tput setaf 3)" BLUE="$(tput setaf 4)" BOLD="$(tput bold)" NORMAL="$(tput sgr0)" else RED="" GREEN="" YELLOW="" BLUE="" BOLD="" NORMAL="" fi # Progress or something start_progress() { while true do echo -ne "#" sleep 1 done } quick_progress() { while true do echo -ne "#" sleep .033 done } long_progress() { while true do echo -ne "#" sleep 3 done } dot_progress() { for i in {1..100}; do printf "." $i -1 $i sleep .033 done echo_c green " 100%{$NORMAL}" sleep 1 } stop_progress() { kill $1 wait $1 2>/dev/null echo -en "\n" } # Case-insensitive for regex matching shopt -s nocasematch # Prepare history mode set -i history -c history -r # Input method get_input() { read -e -p "${BLUE}$1${NORMAL}" "$2" history -s "${!2}" } # Echo in bold echo_b() { if [ "$1" = "-e" ]; then echo -e "${BOLD}$2${NORMAL}" else echo "${BOLD}$1${NORMAL}" fi } # Echo in colour echo_c() { case "$1" in red | r | -red | -r | --red | --r ) echo "${RED}$2${NORMAL}" ;; green | g | -green | -g | --green | --g ) echo "${GREEN}$2${NORMAL}" ;; blue | b | -blue | -b | --blue | --b ) echo "${BLUE}$2${NORMAL}" ;; yellow | y | -yellow | -y | --yellow | --y ) echo "${YELLOW}$2${NORMAL}" ;; * ) echo "$(BOLD)$2$(RESET)" ;; esac } # Get data from parameters if [[ ! -n "$remote_param" && -n "$1" ]]; then remote_param="$1" remote_user="${remote_param%%@*}" remote_ip="${remote_param##*@}" fi # Get input data and save to history save_input() { if [[ ! -n "$remote_user" && ! -n "$1" ]]; then while get_input "SSH Username > " remote_user; do case ${remote_user%% *} in * ) if [ -n "$remote_user" ]; then break else continue fi ;; esac done fi if [[ ! -n "$remote_ip" && ! -n "$1" ]]; then while get_input "SSH Alias/IP-address > " remote_ip; do case ${remote_ip%% *} in * ) if [ -n "$remote_ip" ]; then break else continue fi ;; esac done fi } # Infinitie loop to keep connecting auto_connect() { while true; do exist=`ps aux | grep "$remote_user@$remote_ip" | grep 22` if test -n "$exist" then if test $ALIVE -eq 0 then echo_c yellow "I'm alive since $(date)" fi ALIVE=1 else ALIVE=0 echo_c red "I'm dead... God is bringing me back..." clear printf "${GREEN}Connecting: " for i in {1..100}; do printf "." $i -1 $i sleep .033 done echo_c green " 100%${NORMAL}" sleep 1 clear ssh $remote_user@$remote_ip fi sleep 1 done } main() { save_input auto_connect } main Hope this helps. autossh.sh
  13. Let me explain it quickly, Your original bash script need to be modify whenever you want to backup other database or same database but different server or the damn path. I really do hate it, it will take me over than 30 seconds. That is why I wrote this one to automate that. The purpose of this script is let you enter all needed information to the shell (I also added history to this script, then next time if you still using credential, just press up or down to navigate among them) instead of open the script with vim editor, change them one by one. Of course it is slower if you have only one server, only one database need to backup. But if you have more than one server or database, I should suggest you use my script Good news is, I kept your workflow then you have no worries at all. Cheers!
  14. I added interactive mode into your script, hope it helped to someone is too lazy like me #!/bin/bash #---------------------------------------------- # INTERACTIVE REMOTE DATABASE DUMP SCRIPT #---------------------------------------------- # This work is licensed under a Creative Commons # Attribution-ShareAlike 3.0 Unported License; # see http://creativecommons.org/licenses/by-sa/3.0/ # for more information. #---------------------------------------------- SCRIPT=${0##*/} IFS=$'\n' HISTFILE="$HOME/.remotedump.history" # Use colors, but only if connected to a terminal, and that terminal supports them. if which tput >/dev/null 2>&1; then ncolors=$(tput colors) fi if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then RED="$(tput setaf 1)" GREEN="$(tput setaf 2)" YELLOW="$(tput setaf 3)" BLUE="$(tput setaf 4)" BOLD="$(tput bold)" NORMAL="$(tput sgr0)" else RED="" GREEN="" YELLOW="" BLUE="" BOLD="" NORMAL="" fi # Case-insensitive for regex matching shopt -s nocasematch # Prepare history mode set -i history -c history -r # Input method text get_input() { read -e -p "${BLUE}$1${NORMAL}" "$2" history -s "${!2}" } # Input method password get_input_pw() { read -s -p "${BLUE}$1${NORMAL}" "$2" history -s "${!2}" } # Echo in bold echo_b() { if [ "$1" = "-e" ]; then echo -e "${BOLD}$2${NORMAL}" else echo "${BOLD}$1${NORMAL}" fi } # Echo in colour echo_c() { case "$1" in red | r | -red | -r | --red | --r ) echo "${RED}$2${NORMAL}" ;; green | g | -green | -g | --green | --g ) echo "${GREEN}$2${NORMAL}" ;; blue | b | -blue | -b | --blue | --b ) echo "${BLUE}$2${NORMAL}" ;; yellow | y | -yellow | -y | --yellow | --y ) echo "${YELLOW}$2${NORMAL}" ;; * ) echo "$(BOLD)$2$(RESET)" ;; esac } # Get input data and save to history save_input() { if [[ ! -n "$local_dir" ]]; then while get_input "Local DB Directory > " local_dir; do case ${local_dir%% *} in * ) if [ -n "$local_dir" ]; then break else continue fi ;; esac done fi if [[ ! -n "$remote_user" ]]; then while get_input "SSH Username > " remote_user; do case ${remote_user%% *} in * ) if [ -n "$remote_user" ]; then break else continue fi ;; esac done fi if [[ ! -n "$remote_ip" ]]; then while get_input "SSH Aliases/IP-address > " remote_ip; do case ${remote_ip%% *} in * ) if [ -n "$remote_ip" ]; then break else continue fi ;; esac done fi if [[ ! -n "$remote_dir" ]]; then while get_input "Remote Backup Directory > " local_dir; do case ${remote_dir%% *} in * ) if [ -n "$remote_dir" ]; then break else continue fi ;; esac done fi if [[ ! -n "$db_user" ]]; then while get_input "DB Username > " local_dir; do case ${db_user%% *} in * ) if [ -n "$db_user" ]; then break else continue fi ;; esac done fi if [[ ! -n "$db_password" ]]; then while get_input_pw "DB Password > " local_dir; do case ${db_password%% *} in * ) if [ -n "$db_password" ]; then break else continue fi ;; esac done fi if [[ ! -n "$db_name" ]]; then while get_input "DB Name > " local_dir; do case ${db_name%% *} in * ) if [ -n "$db_name" ]; then break else continue fi ;; esac done fi } change_pwd_rsync() { ## CD INTO LOCAL WORKING DIRECTORY ## this is where I keep my local dump SQL files. ## the most recent one is always named dump.sql cd "$local_dir" ## RSYNC LATEST DUMP.SQL FILE TO REMOTE SERVER rsync -avzP dump.sql $remote_user@$remote_ip:$remote_dir wait } remote_dump() { ## SSH INTO SERVER ssh $remote_user@$remote_ip /bin/bash << EOF echo "**************************"; echo "** Connected to remote. **" echo "**************************"; echo ""; ## CD INTO REMOTE WORKING NON-PUBLIC DIRECTORY ## where the dump.sql file was rsynced to cd "$remote_dir" wait sleep 1 ## RUN MYSQLDUMP COMMAND ## save the SQL with date stamp mysqldump --host=localhost --user=$db_user --password=$db_password $db_name > `date +%Y-%m-%d`.sql; echo "***************************************"; echo "** `date +%Y-%m-%d`.SQL has been imported. **" echo "***************************************"; echo ""; wait sleep 1 ## IMPORT DUMP.SQL COMMAND mysql --host=localhost --user=$db_user --password=$db_password $db_name < dump.sql; echo "*********************************"; echo "** DUMP.SQL has been imported. **" echo "*********************************"; echo ""; wait sleep 1 ## REMOVE DUMP.SQL FILE rm dump.sql echo "********************************"; echo "** DUMP.SQL has been removed. **" echo "********************************"; exit EOF } main() { save_input change_pwd_rsync remote_dump } main
  15. Hello @szabesz, Thanks for replying to my topic, as far as my understanding now. All fields are belong to a template, so I can add as much as possible fields to the template right? And in my case, I may have 2 templates, one is book and the other is chapter. I may have template to manage the categories too, because book should be manage under categories. So it will look like this in my imagine: CATEGORY TEMPLATE Category ├── Title ├── Static Block └── Thumbnail BOOK TEMPLATE Book ├── Title ├── Author ├── Publisher ├── ISBN ├── Type (traditional or comic) ├── Rating └── Thumbnail CHAPTER TEMPLATE Chapter ├── No (number of chapter) ├── Title ├── Content ├── Rating (This will affect to rating of the whole book) └── Thumbnail Everything in PW managed by Pages. So for example, I created a new page with name "Hacking & Security" (Category), another one page is child of "Hacking & Security" name "The Art of Deception" and another one is child of previous name "Chapter 1: Introduction" ? It also mean I have to create all chapters of that book as a child page of "The Art of Deception" ? Question 1: Is it possible of creating child of child as I demonstrate above? (Category > Book > Chapter 1 ... N) Question 2: Is it possible to force user must create content of book (at least 1 chapter) whenever they create a new book? I'm looking for a way to create a new admin page to manage books which separate to default "Pages" section, can I ? Question 3: Is it possible to set book page status like Draft, Publish, Under Review...etc ? Is that a field? Question 4: I checked in PW template, and I saw something like $page->title, how is that possible? PW can use name of fields in template without defining it? Thank you once again, Have a good day.
×
×
  • Create New...