Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/19/2016 in all areas

  1. 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
    4 points
  2. Actually you're right Just tweaked AOS so both themes will have centered login. Say hello to the second checkbox in AOS for the default theme Edit: download v050 to log in centered
    4 points
  3. The problem is not the template, but the parent for the page. There's no way of knowing where to put that page. But I understand your confusion. In the beginning this button was only visible if you had created the necessary parent/child setup for templates, so at least the one setting it up knew about it and it had a at least a "useful" option to show the user if the button was visible. Now that the "Bookmarks" thing is always available this intermediate step is no longer necessary for the button to show up. I'm also not sure if this is really the correct place for the bookmark creation in the first place.
    4 points
  4. If you've control over the server there's also mosh, which is a more stable alternative to ssh with mobile connections in mind.
    4 points
  5. No, sadly I don't own a Tesla Model S. Instead I own a 1994 Mazda. But with getting ProcessWire 3.x ready to release, I didn't have a lot to write about this week. So figured, why not chat about something else I'm passionate about (this is a blog after all). Last weekend, I got to pretend that I owned a brand new 2016 Tesla Model S (P90D) for two days and a couple hundred miles. I was so inspired by it, I figured why not write something. We'll even attempt to draw some parallels with ProcessWire. This post also covers updates to several 1st party modules. https://processwire.com/blog/posts/tesla-model-s/
    3 points
  6. +1 for hiding the button by default (re-move the bookmark-thing from it) @Kai: I'm with you. The (unconfigured) button at such a prominent position is not useful. It produces confusion. But to clarify: the default behave of creating a new page in PW is to select / click on the parent page and select [new] from the popup link list. As LK has said, PW needs to know what page should be the parent for the new page. And now, imagine a site with lots (multiple thousand!) pages and lots of templates and a deep hirarchical tree structure. Do you have it? It would be very uncomfortable to first have to navigate deeply into the hirarchy and have to use the pagination too, before one coud select the parent page for creating a new one. This is the situation for what the ADD-NEW button was created for. Devs can setup template family relations and decide to display an AddNew link for a specific page type there. Now, when an autor / editor need to create a new page of that specific type, which parent is deep into the tree hirarchy, they only need to select it from the big ADD-NEW button and PW does the rest. It is a very fine, time saving, useful and comfortable feature. (when it not is showing up unconfigured ) We will add it to the issue list.
    3 points
  7. It's not there by default because you can have multiple types of pages (different templates), by setting up a parent and child processwire knows what kind of page you want to create.
    3 points
  8. Two major changes this morning! 1. The "Variables" panel is now called "Template Resources" and contains: variables, constants, user defined functions, and included files. 2. The Console panel now also has access to any functions defined in any included files. In this example I am calling the renderNav() function from the _funct.php file.
    2 points
  9. @Kai Go to the template for the page you want to have an add new button/link, on the family tab look for "Show in the add-page shortcut menu?". If not there add a parent and child template and it should appear.
    2 points
  10. v049 is uploaded, featuring centered login page for RenoTweak and some modal Module edit fixes/improvements.
    2 points
  11. Hi! Take a look at Repeater Matrix. Not really a drag-drop system like Visual Composer, but it lets you to define layout presets, edit and reorder them etc.
    2 points
  12. That looks nice. I use Uptime Robot and it's been enlightening how much downtime one of my shared accounts goes down. The email feature IMHO is the most useful part.
    2 points
  13. Mostly using Pingdom and Nagios. Pingdom is for personal projects and as a backup for cases where Nagios itself might've gone down, while Nagios is for anything where I really need a "full-featured" monitoring service. PHP Server Monitor seems like a nice tool, though judging from their documentation (didn't install, so please let me know if I got this wrong) it seems to lack some features I've grown accustomed to: customisable user groups and per-group behaviour, different actions based on time and day/date, service/server specific actions, SNMP support and/or support for custom check logic, etc. If you just want to know whether each specific server/service is up and have a reason to avoid hosted services like Pingdom, StatusCake and UptimeRobot, this does indeed seem like a good tool. For most use cases I'd still recommend a hosted solution, mainly because a) ease of use and b) they pretty much guarantee that the monitor itself won't suddenly die without a notice
    2 points
  14. 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!
    2 points
  15. Ok, the new Dumps Recorder Panel is now available. If you have this panel enabled, all dumps sent via bd() calls will automatically be stored and displayed in this panel until you click the "Clear Dumps" button. Keep in mind that dumps of PW objects can be very large, so it pays to keep this cleaned up very regularly. In case you didn't follow the discussion above, this panel is great for when there are more than one AJAX call which would replace the core dumps panel content with the last call meaning you may completely miss the dump you are interested in. It will also be handy if there are multiple redirects going one. It may also be useful when you want to compare the values of dumping the same variable/object from different pages. I am sure there are use use cases as well. I hope you'll find it a useful addition. @tpr - I tested the situation you described with a repeater and the bd() from your AOS module and this new panel works great for recording these calls. I updated your test install so you can see it in action there. Let me know if anyone has any problems/suggestions for this.
    2 points
  16. the way i do it is to create a Runtime Markup field that outputs a value, for example the name of container page template; then you can reference that value in your conditional visibility.
    2 points
  17. AdminOnSteroids Various admin tweaks to enhance ProcessWire admin. http://modules.processwire.com/modules/admin-on-steroids/ https://github.com/rolandtoth/AdminOnSteroids
    1 point
  18. From the usability point, clicking the "Add New" button should 100 % add a new page. We are on the site "Pages". What else should a user expect... I am also very sure that most of the users will not understand the meaning of "bookmarks". This should be fixed.
    1 point
  19. i'm using http://www.phpservermonitor.org/ since some days and its nice. you need a second server of course. are you using any other tools?
    1 point
  20. I've been using autossh on a CentOS 7 server for a year. autossh has been in the repositories for fedora/centos for many years and is definitely not forgotten. Just the other day there were two threads about autossh at the linuxquestions.org forums I'd pick another name to prevent name conflicts.
    1 point
  21. Picking "autossh" as command name is a bit of a bad choice in my option, since a similarly named command (and *nix package) with an identical use case has been around for more than 12 years.
    1 point
  22. I'm using NodeQuery to monitor all servers I have. It is SaaS and quite useful to me.
    1 point
  23. Updated TemplateFileHelper Repo: https://bitbucket.org/pwFoo/templatefilehelper/src/ Created a first initial commit AjaxIntercoolerJS https://bitbucket.org/pwFoo/ajaxintercoolerjs/src Both dev / unstable!!!
    1 point
  24. The Dump Recorder looks great, but there's one issue: after a number of items, the admin loads very slow. Not sure how to overcome this, maybe setting a max limit? Apart from that, how about adding new items to the top? Plus having the normal Dump and Dump Recorder at the same time seems superfluous. Sometimes I don't know in which panel I'm seeing, but of course it's maybe just me.
    1 point
  25. Thanks! You mean the profields table, right? Just checked it and there's a problem: the markup doesn't tell anything about the field type so IUC doesn't fired. I'll see if I can hook and add a class.
    1 point
  26. What a great module! Small feature wish (if this is possible): Can the url helper also handle URL fields within table fields?
    1 point
  27. hi adrian, what do you think of making it auto-clear by default and have an option to keep them just when the user wants it. similar to the sticky option.
    1 point
  28. Just dropped by to say that I have the same setup on my laptop (MAMP + php7 + PW3), and I was able to migrate the site to live (lamp + php7) without any hassles. In my view, PW version is not the reason. One suggestion I have to troubleshoot this situation: -- Load the default, out of the box PW3 on your hosting. -- If that works, then gradually add modules and import templates + fields one at a time until you hit the error.
    1 point
  29. The Console Panel now also has access to any template variables that you might have defined yourself. The screenshot shows dumping of two custom defined variables via the console (I have included the content of the variables panel so you can see where they are coming from). This should make testing code snippets in the context of the template of a specific page much easier. The one caveat is that currently (hopefully I'll find a way around this) to access to these variables requires including the template file a second time. In most situations this probably won't be a problem, but if the page using the PW API to add/modify/delete any content or similar, then it will be processed twice. So, for the moment, this functionality requires checking the "Allow access to template variables" checkbox - otherwise you'll get an "Undefined variable" error. Hope you all find this useful!
    1 point
  30. Good news - the Variables panel now works without the file compiler - which also means you can use it with PW 2.x as well!
    1 point
  31. On another note - I am seeing more issues with PW's SessionHandlerDB module - it seems to affect the loading of the AJAX bar when using vanilla JS. Without it everything works great. I'll be putting together a troubleshooting section on the support blog post sometime soon will all the issues like this.
    1 point
  32. WHOA! I'm trying to figure out what all this does #BashNewb
    1 point
  33. 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
    1 point
  34. Thank you both for your answers. Sorry for my late response, but unfortunately I hadn't got the time to test until now. @Can Exactly that is the reason why I would prefer PW as middleware. Because it doesn't care. Turns out, I couldn't get any response, because I requested the JSON from a PW installation hosted on my local machine using MAMP. After uploading the installation to a server I get a response. I forgot about, that you could set the header content-type on a template basis. That is easier than setting it in the template file. I am running PW 3.0.28 devns and my template setup looks like the above example for now. Right now I am just experimenting if PW would fit as a good solution. @clsource Thank you for the useful resources. I haven't done anything with REST yet, but will have a closer look. Regards, Andreas
    1 point
×
×
  • Create New...